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


Groups > comp.lang.python > #53632

Re: Dealing with \r in CSV fields in Python2.4

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!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '"""': 0.07; 'string': 0.09; 'newline': 0.09; 'subject:fields': 0.09; 'to:addr:pobox.com': 0.09; 'to:addr:skip': 0.09; 'cc:addr:python- list': 0.11; '-tkc': 0.16; '[1].': 0.16; '\\n,': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'hard-coded': 0.16; 'newlines': 0.16; 'subject:CSV': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'issue.': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'recognize': 0.24; 'skip': 0.24; 'specify': 0.24; 'header:In-Reply-To:1': 0.27; '[1]': 0.29; 'dos': 0.30; "i'm": 0.30; 'lines': 0.31; 'quite': 0.32; 'url:python': 0.33; 'reader': 0.33; 'actual': 0.34; 'subject:with': 0.35; "can't": 0.35; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'feed': 0.38; 'url:library': 0.38; 'anything': 0.39; 'does': 0.39; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'behavior': 0.77; 'received:50.22': 0.84
Date Wed, 4 Sep 2013 10:32:48 -0500
From Tim Chase <python.list@tim.thechases.com>
To Skip Montanaro <skip@pobox.com>
Subject Re: Dealing with \r in CSV fields in Python2.4
In-Reply-To <CANc-5Uz1=_R3J4g5svRUJL0JpA8zGVQi+gkhjoc+FP7-tJN83g@mail.gmail.com>
References <20130904100403.163b42bd@bigbox.christie.dr> <CANc-5Uz1=_R3J4g5svRUJL0JpA8zGVQi+gkhjoc+FP7-tJN83g@mail.gmail.com>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Get-Message-Sender-Via boston.accountservergroup.com: none
Cc Python <python-list@python.org>
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.49.1378308700.5461.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378308700 news.xs4all.nl 15959 [2001:888:2000:d::a6]:41090
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53632

Show key headers only | View raw


On 2013-09-04 10:20, Skip Montanaro wrote:
> >   _csv.Error: newline inside string
> 
> How are the lines actually terminated, with \r\n or with just \n? If
> it's just \n, what happens if you specify \n as the line terminator?

Unfortunately, the customer feed contains DOS newlines ("\r\n").

I'm not quite sure what """
Note
The reader is hard-coded to recognize either '\r' or '\n' as
end-of-line, and ignores lineterminator. This behavior may change in
the future.
""" means at [1].  Does that mean that efforts to change the
lineterminator don't have any effect? Or that you can't (currently)
specify anything other than "\r" or "\n"?  Though that is a bit
tangent to the actual issue.

-tkc


[1] http://docs.python.org/2/library/csv.html



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


Thread

Re: Dealing with \r in CSV fields in Python2.4 Tim Chase <python.list@tim.thechases.com> - 2013-09-04 10:32 -0500

csiph-web