Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #11279
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'variable,': 0.07; '__future__': 0.09; 'generators': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:string': 0.09; 'valueerror:': 0.09; 'def': 0.15; 'delimited': 0.16; 'martelli': 0.16; 'more:': 0.16; 'received:dip.t-dialin.net': 0.16; 'received:t-dialin.net': 0.16; 'subject:Processing': 0.16; 'wrote:': 0.16; 'processed': 0.18; 'memory': 0.21; 'wondered': 0.23; 'variable': 0.24; 'string': 0.26; 'separate': 0.28; 'import': 0.28; 'yield': 0.29; 'from:addr:web.de': 0.30; 'item,': 0.30; 'pattern': 0.30; 'separately.': 0.30; 'alex': 0.31; 'ps:': 0.32; 'break': 0.32; "what's": 0.33; 'to:addr:python-list': 0.33; 'like:': 0.34; 'limitations': 0.34; 'try:': 0.34; 'header:X -Complaints-To:1': 0.35; 'url:python': 0.36; 'url:pipermail': 0.37; 'run': 0.37; 'but': 0.37; 'could': 0.38; 'received:org': 0.38; 'url:org': 0.38; 'subject:: ': 0.39; 'header:Mime- Version:1': 0.39; "there's": 0.39; "couldn't": 0.39; 'to:addr:python.org': 0.39; 'might': 0.40; 'more': 0.60; 'relevant': 0.69; 'data?': 0.84; 'otten': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: Processing a large string |
| Date | Fri, 12 Aug 2011 16:48:10 +0200 |
| Organization | None |
| References | <b16af723-854c-449d-8b45-565d73579e17@br5g2000vbb.googlegroups.com> <j22oqv$9ro$1@solani.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p5084b3bb.dip.t-dialin.net |
| 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.2220.1313160461.1164.python-list@python.org> (permalink) |
| Lines | 40 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1313160461 news.xs4all.nl 23861 [2001:888:2000:d::a6]:55028 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:11279 |
Show key headers only | View raw
Peter Otten wrote: > goldtech wrote: >> Say I have a very big string with a pattern like: >> >> akakksssk3dhdhdhdbddb3dkdkdkddk3dmdmdmd3dkdkdkdk3asnsn..... >> >> I want to split the sting into separate parts on the "3" and process >> each part separately. I might run into memory limitations if I use >> "split" and get a big array(?) I wondered if there's a way I could >> read (stream?) the string from start to finish and read what's >> delimited by the "3" into a variable, process the smaller string >> variable then append/build a new string with the processed data? > PS: This has come up before, but I couldn't find the relevant threads... Alex Martelli a looong time ago: > from __future__ import generators > > def splitby(fileobj, splitter, bufsize=8192): > buf = '' > > while True: > try: > item, buf = buf.split(splitter, 1) > except ValueError: > more = fileobj.read(bufsize) > if not more: break > buf += more > else: > yield item + splitter > > if buf: > yield buf http://mail.python.org/pipermail/python-list/2002-September/770673.html
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Processing a large string goldtech <goldtech@worldpost.com> - 2011-08-11 19:03 -0700
Re: Processing a large string MRAB <python@mrabarnett.plus.com> - 2011-08-12 03:15 +0100
Re: Processing a large string Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-12 12:30 +1000
Re: Processing a large string Nobody <nobody@nowhere.com> - 2011-08-12 05:11 +0100
Re: Processing a large string Peter Otten <__peter__@web.de> - 2011-08-12 10:39 +0200
Re: Processing a large string goldtech <goldtech@worldpost.com> - 2011-08-12 06:36 -0700
Re: Processing a large string Peter Otten <__peter__@web.de> - 2011-08-12 16:48 +0200
Re: Processing a large string Paul Rudin <paul.nospam@rudin.co.uk> - 2011-08-28 20:18 +0100
csiph-web