csv read _csv.Error: line contains NULL byte
mail at timgolden.me.uk
Fri Mar 21 15:59:01 CET 2014
On 21/03/2014 14:46, chip9munk at gmail.com wrote:
> I am sorry I do not understand how to get to each row in this way.
> Please could you explain also this:
> If I define this function,
> how do I change my for loop to get each row?
Does this help?
# log the problem or whatever
print("Problem with some row")
if __name__ == '__main__':
# Generate malformed csv file for
# demonstration purposes
with open("temp.csv", "w") as fout:
# Open the malformed file for reading, fire up a
# conventional CSV reader over it, wrap that reader
# in our "unfussy" generator and enumerate over that
with open("temp.csv") as fin:
reader = unfussy_reader(csv.reader(fin))
for n, row in enumerate(reader):
print(n, "=>", row)
More information about the Python-list