Skip to content

Instantly share code, notes, and snippets.

@LadyKerr
Created August 23, 2023 02:11
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LadyKerr/0ee164ccfe6f05f77c812bd6ecbc3fb6 to your computer and use it in GitHub Desktop.
Save LadyKerr/0ee164ccfe6f05f77c812bd6ecbc3fb6 to your computer and use it in GitHub Desktop.
Convert TSV to CSV with Python - code generated by GitHub Copilot
import csv
with open('ruby-study-guide.tsv', 'r') as tsvfile:
reader = csv.reader(tsvfile, delimiter='\t')
with open('ruby-study-guide.csv', 'w') as csvfile:
writer = csv.writer(csvfile)
for row in reader:
writer.writerow(row)
@LadyKerr
Copy link
Author

To convert TSV to CSV with this script:

  • copy/paste the code to a file with the .py extension. For example, tsv_to_csv.py
  • add your TSV file in the same directory as the script
  • open your terminal and run python [[name of your file]]. For example, python tsv_to_csv.py and cick enter
  • Your CSV file will be automagically outputted in the same directory as your other files

A note:

I was able to generate this code with the help of GitHub Copilot Chat. See conversation below:

Screenshot 2023-08-22 at 9 15 32 PM

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