How I can write below zip list to csv file in python?
[{'date': '2015/01/01 00:00', 'v': 96.5},
{'date': '2015/01/01 00:01', 'v': 97.0},
{'date': '2015/01/01 00:02', 'v': 93.75},
{'date': '2015/01/01 00:03', 'v': 96.0},
{'date': '2015/01/01 00:04', 'v': 94.5}
I have this error:
_csv.Error: sequence expected
My code is here:
import csv
res = zip_list
csvfile = "/home/stm/PycharmProjects/isbak_trafik/example.csv"
with open(csvfile, "w") as output:
writer = csv.writer(output, lineterminator='\n')
writer.writerows(res)
csv.DictWriter
. Or writedict.values()
– Seismoscope