Created
July 5, 2018 12:12
-
-
Save rafaelhenrique/93883a33de10742106b32bff4dbc0576 to your computer and use it in GitHub Desktop.
Write 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
import csv | |
result = [{'field1': 'teste', 'field2': 'teste'}, {'field1': 'teste1', 'field2': 'teste1'}] | |
with open('file.csv', 'w', encoding='utf-8') as csvfile: | |
fieldnames = ['field1', 'field2'] | |
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) | |
writer.writeheader() | |
for row in result: | |
writer.writerow(row) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment