Skip to content

Instantly share code, notes, and snippets.

@jachin
Created June 21, 2011 04:32
Show Gist options
  • Save jachin/1037244 to your computer and use it in GitHub Desktop.
Save jachin/1037244 to your computer and use it in GitHub Desktop.
Convert CSV file to Pipe Delineated File
import argparse
import csv
parser = argparse.ArgumentParser(description='Converts a regular CSV to a piple delimited file with no quotes.')
parser.add_argument('csv_file', help='The CSV file to parse.')
args = parser.parse_args()
csv_reader = csv.reader(open(args.csv_file, 'rb'), delimiter=',', quotechar='"')
for row in csv_reader:
row = '|'.join(row)
row = row.replace('\n', '')
row = row.replace('\r', '')
print row
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment