Skip to content

Instantly share code, notes, and snippets.

@cyriac
Created August 11, 2014 06:26
Show Gist options
  • Save cyriac/63d35b54f64af4290908 to your computer and use it in GitHub Desktop.
Save cyriac/63d35b54f64af4290908 to your computer and use it in GitHub Desktop.
Python snippet to convert list of homogenous dict to csv
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