From 5631b3cc4c3847b10e4a339486ab10d630b3b846 Mon Sep 17 00:00:00 2001 From: Michael Herman Date: Thu, 16 Oct 2014 10:35:23 -0500 Subject: [PATCH] tsv to csv --- 19_tsv-to-csv.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 19_tsv-to-csv.py diff --git a/19_tsv-to-csv.py b/19_tsv-to-csv.py new file mode 100644 index 0000000..f10deed --- /dev/null +++ b/19_tsv-to-csv.py @@ -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])