Thursday 19 January 2017

converting csv to tsv file-Python

import re
csv = open('D:\csv to tsv\SampleCSVFile_2kb.csv', 'r')
tsv = open('D:\csv to tsv\ggtsvFile.tsv', 'w')
for fileContent in csv:
    fileContent = re.sub(",", "\t", fileContent)
    print(fileContent)
    tsv.write(fileContent)
tsv.close()

No comments:

Post a Comment