Skip to content

Instantly share code, notes, and snippets.

@jtrive84
Created November 27, 2016 05:02
Show Gist options
  • Save jtrive84/f1892f37dc9c751e0e6d9581e2f5d04c to your computer and use it in GitHub Desktop.
Save jtrive84/f1892f37dc9c751e0e6d9581e2f5d04c to your computer and use it in GitHub Desktop.
Suppress double-spaced output in Python 3 by specifying `lineterminator="\n"` to csv.writer instance.
"""
Suppress double-spaced output in Python 3 by specifying `lineterminator="\n"`
to csv.writer instance.
"""
import csv
fsrc_pth = "src_pth"
fdst_pth = "dst_pth"
with open(fdst_pth, 'w') as f1:
fdst = csv.writer(f1, lineterminator="\n")
with open(fsrc_pth, 'r') as f2:
fsrc = csv.reader(f2)
for rec in fsrc: fdst.writerow(rec)
assert f1.closed
assert f2.closed
print("Finished")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment