Created
August 11, 2014 06:26
-
-
Save cyriac/63d35b54f64af4290908 to your computer and use it in GitHub Desktop.
Python snippet to convert list of homogenous dict to csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
list_of_dict = [.....] | |
keys = list_of_dict[0].keys() | |
f = open('file.csv', 'wb') | |
dict_writer = csv.DictWriter(f, keys) | |
dict_writer.writer.writerow(keys) | |
dict_writer.writerows(list_of_dict) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment