Skip to content

Instantly share code, notes, and snippets.

@dansimau
Created November 22, 2013 14:25
Show Gist options
  • Save dansimau/7600667 to your computer and use it in GitHub Desktop.
Save dansimau/7600667 to your computer and use it in GitHub Desktop.
Convert TSV to CSV.
import sys
import csv
tsvin = csv.reader(sys.stdin, dialect=csv.excel_tab)
csvout = csv.writer(sys.stdout, dialect=csv.excel)
for row in tsvin:
# Force all fields to be string-based (Excel specific)
for i, val in enumerate(row):
row[i] = '="%s"' % val
csvout.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment