Created
September 16, 2011 12:20
-
-
Save gka/1222000 to your computer and use it in GitHub Desktop.
Converting a comma-separated and quoted file into a tab-separated and unquoted file
This file contains 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/env python2.7 | |
""" | |
No more trouble with comma-separated and quoted CSV files. | |
""" | |
import csv, sys | |
if len(sys.argv) != 3: print 'Usage:\ncsv2tsv fromfile.csv tofile.tsv' | |
file_in = sys.argv[1] | |
file_out = sys.argv[2] | |
data = csv.reader(open(file_in, 'r')) | |
fout = open(file_out,'w') | |
out = csv.writer(fout, dialect='excel-tab') | |
for r in data: out.writerow(r) | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment