Skip to content

Instantly share code, notes, and snippets.

@hornc
Last active September 25, 2025 03:56
Show Gist options
  • Save hornc/8ab7c455f351e8f1ef96ec8623041a15 to your computer and use it in GitHub Desktop.
Save hornc/8ab7c455f351e8f1ef96ec8623041a15 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import argparse
import csv
ABOUT = """
Convert .csv (Comma Separated Value) file to .tsv (Tab Separated Value) file.
Output to STDOUT. (redirect to a file or another process)
"""
def main():
parser = argparse.ArgumentParser(description=ABOUT)
parser.add_argument('csv', help='CSV file to convert')
args = parser.parse_args()
infile = args.csv
with open(infile, newline='') as csvfile:
csvreader = csv.reader(csvfile, delimiter=',')
for row in csvreader:
print('\t'.join(row))
if __name__ == '__main__':
main()
@hornc
Copy link
Author

hornc commented Sep 25, 2025

download and set +x to the script:

wget https://gist.githubusercontent.com/hornc/8ab7c455f351e8f1ef96ec8623041a15/raw/676d25256439f5187791124ffa4cc3b86287cde7/csv2tsv.py && chmod +x csv2tsv.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment