I have JSON data which I am pulling in via API.
here's my code
# list of each api url to use
link =[]
#for every id in the accounts , create a new url link into the link list
for id in accounts:
link.append('https://example.ie:0000/v123/accounts/'+id+'/users')
accountReq = []
for i in link:
accountReq.append(requests.get(i, headers=headers).json())
with open('masterSheet.txt', 'x') as f:
for each in accountReq:
account = each['data']
for data in account:
list=(data['username']+" "+" ",data['first_name'],data['last_name'])
f.write(str(list)+"\n")
This pulls in data no problem . If I do
print(data['username']+" "+" ",data['first_name'],data['last_name'])
I get all of the data back , around 500lines.
However my problem I am having is when I try to write to my file , it writes about 8lines of data and then stops running with no errors.
I'm assuming its due to the data size. How can I fix my issue of not printing all of the data to the .txt file??