Created
June 21, 2011 04:32
-
-
Save jachin/1037244 to your computer and use it in GitHub Desktop.
Convert CSV file to Pipe Delineated File
This file contains hidden or 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 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