-
-
Save jj1bdx/c499114ddcad9b83f498 to your computer and use it in GitHub Desktop.
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/env python | |
import sys,csv | |
for row in csv.reader(sys.stdin): | |
print "\t".join(row) |
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
python -c "`printf '%s\n' 'import sys,csv' 'for row in csv.reader(sys.stdin):' ' print "\t".join(row)'`" |
even better, it does all .csv
files in os.getcwd()
surprisingly quick too.
#!/usr/bin/env python
import sys
import csv
import os
#file = sys.argv[1]
for file in os.listdir(os.getcwd()):
if file.endswith('.csv'):
with open(file) as f:
with open(file.replace('.csv', '.txt'), 'w+') as f2:
for row in csv.reader(f):
f2.write('\t'.join(row) + '\n')
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use this, e.g.
./csv2tsv.py Nutrient.csv
outputs tsv
Nutrient.txt