csv read _csv.Error: line contains NULL byte
Mark Lawrence
breamoreboy at yahoo.co.uk
Fri Mar 21 11:15:02 EDT 2014
On 21/03/2014 14:46, chip9munk at gmail.com wrote:
> On Friday, March 21, 2014 2:39:37 PM UTC+1, Tim Golden wrote:
>
>> Without disturbing your existing code too much, you could wrap the
>>
>> input_reader in a generator which skips malformed lines. That would look
>>
>> something like this:
>>
>>
>>
>> def unfussy_reader(reader):
>>
>> while True:
>>
>> try:
>>
>> yield next(reader)
>>
>> except csv.Error:
>>
>> # log the problem or whatever
>>
>> continue
>
>
> 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?
>
> Thanks!
>
I'm pleased to see that you have answers. In return would you either
use the mailing list
https://mail.python.org/mailman/listinfo/python-list or read and action
this https://wiki.python.org/moin/GoogleGroupsPython to prevent us
seeing double line spacing and single line paragraphs, thanks.
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
More information about the Python-list
mailing list