Skip to content

Instantly share code, notes, and snippets.

@stucka
Created July 7, 2017 22:19
Show Gist options
  • Save stucka/de4f710e385bfe6376dd4deef1d52d6c to your computer and use it in GitHub Desktop.
Save stucka/de4f710e385bfe6376dd4deef1d52d6c to your computer and use it in GitHub Desktop.
Python -- write from ordered dictionary OrderedDict to csv file
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