I am trying to write a program that looks at a .CSV file (input.csv) and overwrites only lines that start with a specific element (corrected.csv), as indicated in a text file (output.txt).
Here's what my program looks like right now:
import csv lines = [] with open('output.txt','r') as f: for line in f.readlines(): lines.append(line[:-1]) with open('corrected.csv','w') as correct: writer = csv.writer(correct, dialect = 'excel') with open('input.csv', 'r') as mycsv: reader = csv.reader(mycsv) for row in reader: if row[0] not in lines: writer.writerow(row)
Unfortunately, I keep getting this error, and I don't know what that means.
Traceback (most recent call last): File "C:\Python32\Sample Program\csvParser.py", line 12, in <module> for row in reader: _csv.Error: line contains NULL byte
We thank all the people here to even bring me to this point.
python csv
James Roseman Oct. 25 '11 at 19:39 2011-10-25 19:39
source share