Skip to content

Instantly share code, notes, and snippets.

@ongzexuan
Created June 17, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ongzexuan/3695a24b645446543f363d6208388540 to your computer and use it in GitHub Desktop.
Save ongzexuan/3695a24b645446543f363d6208388540 to your computer and use it in GitHub Desktop.
Example of writing to CSV file with quotations and line terminator
# 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