Python DictWriter
. , , . :
import csv
zip_list = [
{'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}]
csvfile = "/home/stm/PycharmProjects/isbak_trafik/example.csv"
with open(csvfile, "wb") as output:
writer = csv.DictWriter(output, fieldnames=['date', 'v'])
writer.writeheader()
writer.writerows(zip_list)
:
date,v
2015/01/01 00:00,96.5
2015/01/01 00:01,97.0
2015/01/01 00:02,93.75
2015/01/01 00:03,96.0
2015/01/01 00:04,94.5