Skip to content

Instantly share code, notes, and snippets.

@danyaljj
Created June 25, 2015 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danyaljj/147b7d513001154feeec to your computer and use it in GitHub Desktop.
Save danyaljj/147b7d513001154feeec to your computer and use it in GitHub Desktop.
Convert TSV file to CSV file in Python
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