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

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; '21,': 0.07; 'friday,': 0.09; 'function,': 0.09; 'lawrence': 0.09; 'lines.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; 'def': 0.12; 'language.': 0.14; 'golden': 0.16; 'paragraphs,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skips': 0.16; 'spacing': 0.16; 'true:': 0.16; 'prevent': 0.16; 'language': 0.16; 'wrote:': 0.18; 'thanks.': 0.20; 'header:User-Agent:1': 0.23; 'url:moin': 0.24; '---': 0.24; 'define': 0.26; 'this:': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.31; 'url:wiki': 0.31; 'thanks!': 0.32; 'url:python': 0.33; 'could': 0.34; 'problem': 0.35; 'except': 0.35; 'skip:u 20': 0.35; 'something': 0.35; 'yield': 0.36; 'url:listinfo': 0.36; 'url:org': 0.36; 'too': 0.37; 'list': 0.37; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'mailing': 0.39; 'either': 0.39; 'received:org': 0.40; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'free': 0.61; 'march': 0.61; 'viruses': 0.61; 'email addr:gmail.com': 0.63; 'protection': 0.63; 'our': 0.64; 'antivirus': 0.68; 'much,': 0.84; 'received:2': 0.84; 'subject:read': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: csv read _csv.Error: line contains NULL byte
Date Fri, 21 Mar 2014 15:15:02 +0000
References <22aeefa3-cf82-457c-ab85-6f0366ff7b4e@googlegroups.com> <mailman.8354.1395409181.18130.python-list@python.org> <fefcec40-3bd9-4a94-9ae8-4f214fce2302@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host host-2-98-198-214.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
In-Reply-To <fefcec40-3bd9-4a94-9ae8-4f214fce2302@googlegroups.com>
X-Antivirus avast! (VPS 140321-0, 21/03/2014), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.8362.1395414925.18130.python-list@python.org> (permalink)
Lines 52
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1395414925 news.xs4all.nl 2883 [2001:888:2000:d::a6]:52197
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:68699

Show key headers only | 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