Created
June 17, 2019 16:10
-
-
Save ongzexuan/3695a24b645446543f363d6208388540 to your computer and use it in GitHub Desktop.
Example of writing to CSV file with quotations and line terminator
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
# Write to staging file | |
with open(TEMP_FILE, 'w') as f: | |
writer = csv.DictWriter(f, fieldnames=HEADERS), | |
quoting=csv.QUOTE_ALL, | |
lineterminator='\n') | |
writer.writeheader() | |
for data in staging_rows: | |
writer.writerow(data) | |
print('Written to {}'.format(TEMP_FILE)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment