Created
December 14, 2012 09:09
-
-
Save atree/4283900 to your computer and use it in GitHub Desktop.
Quick python script to truncate CSV data elements.
This file contains 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
#/usr/bin/python | |
import csv | |
fout = open('ptype_out.csv', 'w') | |
with open('ptype_in.csv', 'rb') as fin: | |
fin_reader = csv.reader(fin, delimiter='|') | |
for row in fin_reader: | |
new_row = ', '.join(row) | |
new_row = ','.join(new_row.split(',')[:10]) | |
fout.write('"' + new_row + '"\n') | |
fout.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment