Created
March 24, 2012 03:33
-
-
Save rahimnathwani/2177926 to your computer and use it in GitHub Desktop.
Trim the second field in a CSV file down to 3999 characters
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 csv | |
| csvReader = csv.reader(open('input.csv','rb'), delimiter=',',quotechar='"') | |
| csvWriter = csv.writer(open('output.csv','wb'), delimiter=',',quotechar='"',quoting=csv.QUOTE_MINIMAL) | |
| for row in csvReader: | |
| csvWriter.writerow([row[0],row[1][0:3998],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[11],row[12]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment