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


Groups > comp.lang.python > #12523

Re: Text file with mixed end-of-line terminations

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.057
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'newline': 0.09; 'url:peps': 0.09; 'subject:file': 0.13; 'terminates': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'cheers,': 0.18; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'pm,': 0.24; 'aug': 0.24; 'van': 0.26; 'universal': 0.29; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'lines': 0.30; 'url:dev': 0.30; 'alex': 0.31; 'url:library': 0.31; 'chris': 0.32; 'there': 0.33; 'regardless': 0.34; 'uses': 0.35; 'received:209.85.161': 0.35; 'file': 0.36; 'url:python': 0.36; 'involving': 0.37; 'received:google.com': 0.38; 'url:org': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'url:docs': 0.39; 'subject:with': 0.39; '31,': 0.64; 'subject:line': 0.73; 'subject:Text': 0.77; 'sender:addr:chris': 0.84; 'subject:mixed': 0.84; 'url:functions': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=PCfUf9OEgxjzCdQn9TH817qz1wLRine9uOeHM9U67gk=; b=UkZSi+xzxt+ARxkeEmT5n1GjHMYKlwP440A3hDd06hPP9j/QXx65Daelmh1M3jfNwO JDY4aYAxuB1MNwe4dobQT4uw11Ia5ybfUrjLIxskNSneMjSSETxX106SJFOgP6yTbLmL 4Z4pqhPym2H5OWRU0yDVSJl2JHXu4quz2VWSk=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <4e5e8d71$0$2554$e4fe514c@news2.news.xs4all.nl>
References <4e5e8d71$0$2554$e4fe514c@news2.news.xs4all.nl>
Date Wed, 31 Aug 2011 12:58:36 -0700
X-Google-Sender-Auth BEZbNEkelYHQvgznGS4Rgp1QC9s
Subject Re: Text file with mixed end-of-line terminations
From Chris Rebert <clp2@rebertia.com>
To Alex van der Spek <zdoor@xs4all.nl>
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.631.1314820719.27778.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1314820719 news.xs4all.nl 2549 [2001:888:2000:d::a6]:56678
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:12523

Show key headers only | View raw


On Wed, Aug 31, 2011 at 12:37 PM, Alex van der Spek <zdoor@xs4all.nl> wrote:
> I have a text file that uses both '\r' and '\r\n' end-of-line terminations.
>
> The '\r' terminates the first 25 lines or so, the remainder is termiated
> with '\r\n'
<snip>
> Is there a way to make it read one line at a time, regardless of the line
> termination?

Universal Newline Support
http://www.python.org/dev/peps/pep-0278/

http://docs.python.org/library/functions.html#open
(Modes involving "U")

Cheers,
Chris

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


Thread

Text file with mixed end-of-line terminations "Alex van der Spek" <zdoor@xs4all.nl> - 2011-08-31 21:37 +0200
  Re: Text file with mixed end-of-line terminations Chris Rebert <clp2@rebertia.com> - 2011-08-31 12:58 -0700
  Re: Text file with mixed end-of-line terminations woooee <woooee@gmail.com> - 2011-09-01 12:17 -0700

csiph-web