/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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