Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Python garbage collector/memory manager behaving strangely

Reply
Thread Tools

Re: Python garbage collector/memory manager behaving strangely

 
 
Dennis Lee Bieber
Guest
Posts: n/a
 
      09-17-2012
On Mon, 17 Sep 2012 10:28:34 +0800, "Jadhav, Alok"
<(E-Mail Removed)> 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
http://www.velocityreviews.com/forums/(E-Mail Removed) HTTP://wlfraed.home.netcom.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Python garbage collector/memory manager behaving strangely Jadhav, Alok Python 9 11-15-2012 11:20 AM
Re: Python garbage collector/memory manager behaving strangely Robert Miles Python 0 11-01-2012 12:40 AM
RE: Python garbage collector/memory manager behaving strangely Jadhav, Alok Python 0 09-17-2012 02:49 AM
Stateserver behaving strangely =?iso-8859-1?q?Nils Hedstr=f6m ASP .Net 0 02-11-2005 10:04 AM
Help. My PC is behaving strangely kackson Computer Support 2 02-01-2004 03:45 PM



Advertisments