Created
July 7, 2017 22:19
-
-
Save stucka/de4f710e385bfe6376dd4deef1d52d6c to your computer and use it in GitHub Desktop.
Python -- write from ordered dictionary OrderedDict to csv file
This file contains hidden or 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
with open("statereport-geo.csv", 'w', newline='') as csvfile: | |
writer = csv.writer(csvfile) | |
headers = [] | |
for key in rows[0]: | |
headers.append(key) | |
writer.writerow(headers) | |
for row in rows: | |
targetrow = [] | |
for key in headers: | |
targetrow.append(row[key]) | |
writer.writerow(targetrow) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment