Last active
January 24, 2022 08:59
-
-
Save gunchev/53d610f71ca19d0ca17f6624c8f60cd0 to your computer and use it in GitHub Desktop.
Python CSV with unix line terminators
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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import csv | |
def main(): | |
csv.register_dialect('unix', lineterminator='\n', quoting=csv.QUOTE_MINIMAL) | |
with open('unix.csv', 'w') as csv_file: | |
csv_writer = csv.writer(csv_file, dialect='unix') | |
csv_writer.writerow(('test', 'csv', 'with', 'unix', 'line', 'terminators')) | |
csv_writer.writerow(('in', 'python', '.', 'See', 'you', '!')) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment