I have a list with a dictionary type every line, so basically I can walk thru the list in a loop to get each dictionary record. I need to create a csv file from that list and every record is each of the items dictionary on the list.
My list look like :
[{"field1":"field","field2":"field"....},{"field1":"field","field2":"field"....}]
I have done this snippet code below but I'm storing only the headers:
with open('myfile', mode='wt', encoding='utf-8') as myfile:
for lines in data:
myfile.write('\n'.join(lines))
myfile.write('\n')
I was exploring How do I write a Python dictionary to a csv file? but I dont know how to compose this to each line of my list within a loop to guarantee every record is coming from the line list.
I appreciate any help
thanks.