Last active
August 31, 2016 17:03
-
-
Save thomas-maschler/32c77c1f45989d38f56be0eb8e303000 to your computer and use it in GitHub Desktop.
TSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import glob | |
import os | |
csv_path = r"D:\temp\fires_tsv\csv\*" | |
csv_files = glob.glob(csv_path) | |
tsv_path = r"D:\temp\fires_tsv\tsv" | |
if not os.path.exists(tsv_path): | |
os.mkdir(tsv_path) | |
for csv_file in csv_files: | |
with open(csv_file) as c: | |
csv_basename = os.path.basename(csv_file) | |
print csv_basename | |
reader = csv.reader(c, delimiter=',', quotechar='"') | |
with open(os.path.join(tsv_path, os.path.splitext(csv_basename)[0] + ".tsv"), 'wb') as t: | |
writer = csv.writer(t, delimiter='\t', quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
for row in reader: | |
writer.writerow(row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment