Skip to content

Commit 5631b3c

Browse files
committed
tsv to csv
1 parent 648aa0a commit 5631b3c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

19_tsv-to-csv.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import os
2+
import sys
3+
import csv
4+
5+
6+
def convert(input, out):
7+
if os.path.exists(out):
8+
raise ValueError("Output file already exists")
9+
10+
reader = csv.reader(open(input, 'rU'), dialect=csv.excel_tab)
11+
writer = csv.writer(open(out, "wb+"), dialect="excel")
12+
for row in reader:
13+
writer.writerow(row)
14+
15+
if __name__ == "__main__":
16+
convert(sys.argv[1], sys.argv[2])

0 commit comments

Comments
 (0)