Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: Python garbage collector/memory manager behaving strangely (http://www.velocityreviews.com/forums/t952286-re-python-garbage-collector-memory-manager-behaving-strangely.html)

Dennis Lee Bieber 09-17-2012 04:15 AM

Re: Python garbage collector/memory manager behaving strangely
 
On Mon, 17 Sep 2012 10:28:34 +0800, "Jadhav, Alok"
<alok.jadhav@credit-suisse.com> 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/



All times are GMT. The time now is 01:39 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57