Skip to content

Instantly share code, notes, and snippets.

@hideaki-t
Created July 4, 2013 17:53
Show Gist options
  • Save hideaki-t/5929358 to your computer and use it in GitHub Desktop.
Save hideaki-t/5929358 to your computer and use it in GitHub Desktop.
convert CSV file to TSV file
from sys import argv, stdin, stdout
from csv import reader, writer
enc = argv[2] if len(argv) > 2 else "UTF-8"
inputf = open(argv[1], encoding=enc) if len(argv) > 1 else stdin
writer(stdout, lineterminator='\n', delimiter='\t').writerows(reader((x.strip('\r\n') for x in inputf)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment