Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'subject:Python': 0.05; 'chunk': 0.07; 'exit': 0.07; 'function,': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'seen,': 0.09; 'sep': 0.09; '(last': 0.16; 'chunk:': 0.16; 'cleaner': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'true:': 0.16; 'mon,': 0.16; 'specify': 0.17; 'hack': 0.18; 'header:X-Complaints-To:1': 0.28; 'lines': 0.28; 'rest': 0.28; 'subject:/': 0.28; 'character': 0.29; 'attach': 0.30; 'could': 0.32; 'function.': 0.33; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'sometimes': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'characters': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'itself': 0.37; 'previous': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'middle': 0.66; 'dennis': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Python garbage collector/memory manager behaving strangely Date: Mon, 17 Sep 2012 00:15:45 -0400 Organization: > Bestiaria Support Staff < References: <5056871E.7050206@davea.name> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-16-53.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1347855354 news.xs4all.nl 6884 [2001:888:2000:d::a6]:56384 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29361 On Mon, 17 Sep 2012 10:28:34 +0800, "Jadhav, Alok" declaimed the following in gmane.comp.python.general: > - As you have seen, the line separator is not '\n' but its '|\n'. > Sometimes the data itself has '\n' characters in the middle of the line > and only way to find true end of the line is that previous character > should be a bar '|'. I was not able specify end of line using > readlines() function, but I could do it using split() function. > (One hack would be to readlines and combine them until I find '|\n'. is > there a cleaner way to do this?) Then chunk the file... {PSEUDOCODE} last = "" while True: chunk = fin.read(500000) #read 1/2 MB max #and attach to left-overs if not chunk: #EOF, process any left overs processLine(last) break #and exit lines = (last + chunk).split("|\n") last = lines[-1] #save "partial" line for ln in lines[:-1]: #loop over rest processLine(ln) fin.close() -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/