Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68699

Re: csv read _csv.Error: line contains NULL byte

From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: csv read _csv.Error: line contains NULL byte
Date 2014-03-21 15:15 +0000
References <22aeefa3-cf82-457c-ab85-6f0366ff7b4e@googlegroups.com> <mailman.8354.1395409181.18130.python-list@python.org> <fefcec40-3bd9-4a94-9ae8-4f214fce2302@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.8362.1395414925.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 21/03/2014 14:46, chip9munk@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

csv read _csv.Error: line contains NULL byte chip9munk@gmail.com - 2014-03-21 06:29 -0700
  Re: csv read _csv.Error: line contains NULL byte Tim Golden <mail@timgolden.me.uk> - 2014-03-21 13:39 +0000
    Re: csv read _csv.Error: line contains NULL byte chip9munk@gmail.com - 2014-03-21 07:46 -0700
      Re: csv read _csv.Error: line contains NULL byte chip9munk@gmail.com - 2014-03-21 07:59 -0700
      Re: csv read _csv.Error: line contains NULL byte Tim Golden <mail@timgolden.me.uk> - 2014-03-21 14:59 +0000
      Re: csv read _csv.Error: line contains NULL byte Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-03-21 15:15 +0000

csiph-web