Return to Snippet

Revision: 37692
at December 15, 2010 08:43 by jachin


Initial Code
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

Initial URL

                                

Initial Description

                                

Initial Title
Convert CSV file to Pipe Delineated File

Initial Tags
files, csv

Initial Language
Python