I have a list of python dictionaries that I'm trying to write the values into csv file, but for some reason I keep getting _csv.Error: sequence expected
Here is the sample code:
import csv
import os, sys
headers = ['id', 'Info']
data = [{'id': 1, 'Info': 'Example 1'}, {'id': 2, 'Info':'Example 2'}]
with open('all_csv.csv', 'wt') as f:
writer = csv.writer(f, delimiter=',')
writer.writerow(headers)
for each in data:
writer.writerow(each.values())
Any help would be appreciated.