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


Groups > comp.lang.python > #103583

Re: How to read from a file to an arbitrary delimiter efficiently?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: How to read from a file to an arbitrary delimiter efficiently?
Date Sat, 27 Feb 2016 23:18:49 +1100
Lines 14
Message-ID <mailman.174.1456575532.20994.python-list@python.org> (permalink)
References <56cea44e$0$11128$c3e8da3@news.astraweb.com> <mailman.116.1456385901.20994.python-list@python.org> <56d17138$0$1605$c3e8da3$5496439d@news.astraweb.com> <CAPTjJmpv8E7UeRZLzKoyH2Lax7EfqzQDCKvJ7iNCsRQ9odkXtw@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de YzZwdvL6TefoFc2PRx1Z+ALoH/j3FzL7RDzA/8dRW9kw==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:file': 0.07; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'buffer.': 0.09; 'delimiter': 0.09; '"to': 0.16; '*only*': 0.16; '2016': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ideally,': 0.16; 'line")': 0.16; 'losing': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; "wouldn't": 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'feb': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'all.': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'operations,': 0.27; 'went': 0.28; 'coded': 0.29; 'work.': 0.30; "i'd": 0.31; 'possibly': 0.32; 'class': 0.33; 'received:google.com': 0.35; 'next': 0.35; 'could': 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; '(and': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'subject:from': 0.39; 'rather': 0.39; 'your': 0.60; 'more': 0.63; 'different': 0.63; 'chrisa': 0.84; 'subject:read': 0.84; 'to:none': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=li09nq6BzIv96mpnScB7qEE0Ejf11MI0gVjW8V7krHI=; b=PyJ9OvIO710abZtFew9pJVE19OFo9JTLuFOKlqrddTbrGYy2LwKID7wx+es0FqfiTN 7bCE6nH8PkiWmUb32jTFteonFZIQwi7ZCqcmxryQC2GQucY/IxFBDpc3ExyfwIDFuG/4 Pzs+cWkP9zdOPivSWvSywRn9ck4c8opar5hqMEL8/lwxcZfAiKIQ5SdA4X0WUfdohKJe KJVVY5RFPPj4CD/o+amHmlsAJ4G9RGvkfl7PZrL/wwXfouPFo/iCKztBVvlQqL9jAswc tfZhLDjHaiYuDCS0jhtiRTO2oeVHeJiK6f7Z+B7h4Lfe/dTnwWSQ9KiVMxmEuqxxoj7R jl6w==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=li09nq6BzIv96mpnScB7qEE0Ejf11MI0gVjW8V7krHI=; b=LIAPN+s0XndOTfEEMlEZJLBzX/21RlJQSR5gUsjevZqQrJ2O23+4YDSysILDh16y2b p9QaiVmW0vqKyp4F7KiVinCboonXaky670i9CQyOUp5R7uLFLAn0101Jy4h5qABQtH0x irPSTzXbiUcDEzi7jFwJuxy57qonBm6f0EMzG6rxJ/wFNeBRpWEdQBNt+vzyuqyMqJYt 6K1g/r/Y91btE+h4KMdfT75WcoZegB4osSMA+DtbZi0PYIM2ILWzEOLVoqP1XpFWB148 FaCeotJrC4tuuR/y2cNlKmoGs+N6LZVDSp/Ktk02tuoJywymMBGz84A6mkvjHTYe7UrU zsmw==
X-Gm-Message-State AD7BkJL+wNiIvigOjHkZOy8mrD/T1UcwVtKYWWJRSYU1Ej73/j0jYItNmo34wY07nGVwhFpMvLZdO6FgJObCvQ==
X-Received by 10.51.17.34 with SMTP id gb2mr2212744igd.13.1456575529324; Sat, 27 Feb 2016 04:18:49 -0800 (PST)
In-Reply-To <CAPTjJmpv8E7UeRZLzKoyH2Lax7EfqzQDCKvJ7iNCsRQ9odkXtw@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21rc2
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>
Xref csiph.com comp.lang.python:103583

Show key headers only | View raw


On Sat, Feb 27, 2016 at 11:17 PM, Chris Angelico <rosuav@gmail.com> wrote:
>> Ideally, I'd rather not over-read at all. I'd like the user to be able to
>> swap from "read N bytes" to "read to the next delimiter" (and possibly
>> even "read the next line") without losing anything.
>
> If those are the *only* two operations, you should be able to maintain
> your own buffer.

And, I started out by thinking "to next delimiter" and "next line"
were the same thing with different delimiters, but then went and coded
the delimiter so that wouldn't work. Whatevs. If those are the only
*three* operations, the same class with one more method could do it.

ChrisA

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


Thread

How to read from a file to an arbitrary delimiter efficiently? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-02-25 17:50 +1100
  Re: How to read from a file to an arbitrary delimiter efficiently? Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2016-02-25 08:37 +0100
    Re: How to read from a file to an arbitrary delimiter efficiently? Steven D'Aprano <steve@pearwood.info> - 2016-02-27 21:40 +1100
      Re: How to read from a file to an arbitrary delimiter efficiently? Dan Sommers <dan@tombstonezero.net> - 2016-02-27 14:40 +0000
      Re: How to read from a file to an arbitrary delimiter efficiently? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-27 12:03 -0500
        Re: How to read from a file to an arbitrary delimiter efficiently? Marko Rauhamaa <marko@pacujo.net> - 2016-02-27 19:47 +0200
  Re: How to read from a file to an arbitrary delimiter efficiently? Chris Angelico <rosuav@gmail.com> - 2016-02-25 18:30 +1100
    Re: How to read from a file to an arbitrary delimiter efficiently? Steven D'Aprano <steve@pearwood.info> - 2016-02-27 20:49 +1100
      Re: How to read from a file to an arbitrary delimiter efficiently? Chris Angelico <rosuav@gmail.com> - 2016-02-27 23:17 +1100
      Re: How to read from a file to an arbitrary delimiter efficiently? Chris Angelico <rosuav@gmail.com> - 2016-02-27 23:18 +1100
      Re: How to read from a file to an arbitrary delimiter efficiently? Serhiy Storchaka <storchaka@gmail.com> - 2016-02-27 17:23 +0200
  Re: How to read from a file to an arbitrary delimiter efficiently? Paul Rubin <no.email@nospam.invalid> - 2016-02-24 23:48 -0800
    Re: How to read from a file to an arbitrary delimiter efficiently? wxjmfauth@gmail.com - 2016-02-25 06:37 -0800
    Re: How to read from a file to an arbitrary delimiter efficiently? wxjmfauth@gmail.com - 2016-02-25 06:38 -0800
  Re: How to read from a file to an arbitrary delimiter efficiently? BartC <bc@freeuk.com> - 2016-02-27 16:35 +0000
    Re: How to read from a file to an arbitrary delimiter efficiently? BartC <bc@freeuk.com> - 2016-02-27 20:03 +0000
      Re: How to read from a file to an arbitrary delimiter efficiently? BartC <bc@freeuk.com> - 2016-02-27 20:28 +0000
  Re: How to read from a file to an arbitrary delimiter efficiently? Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-02-28 20:28 +0000
  Re: How to read from a file to an arbitrary delimiter efficiently? Tim Delaney <timothy.c.delaney@gmail.com> - 2016-02-29 08:00 +1100

csiph-web