tsv to csv
This commit is contained in:
parent
648aa0a58f
commit
5631b3cc4c
16
19_tsv-to-csv.py
Normal file
16
19_tsv-to-csv.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import csv
|
||||||
|
|
||||||
|
|
||||||
|
def convert(input, out):
|
||||||
|
if os.path.exists(out):
|
||||||
|
raise ValueError("Output file already exists")
|
||||||
|
|
||||||
|
reader = csv.reader(open(input, 'rU'), dialect=csv.excel_tab)
|
||||||
|
writer = csv.writer(open(out, "wb+"), dialect="excel")
|
||||||
|
for row in reader:
|
||||||
|
writer.writerow(row)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
convert(sys.argv[1], sys.argv[2])
|
Loading…
Reference in New Issue
Block a user