Created
June 25, 2015 22:13
-
-
Save danyaljj/147b7d513001154feeec to your computer and use it in GitHub Desktop.
Convert TSV file to CSV file in Python
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
import os | |
import csv | |
import sys | |
csv.field_size_limit(sys.maxsize) | |
for fn in os.listdir('.'): | |
print( os.path.splitext(fn) ) | |
print( os.path.splitext(fn)[1] == ".tsv" ) | |
if os.path.isfile(fn): | |
if not(os.path.splitext(fn)[1]==".tsv"): | |
continue | |
print (fn) | |
csv.writer(file(os.path.splitext(fn)[0] + '.csv', 'w+')).writerows(csv.reader(open(fn), delimiter="\t")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment