Re: Python garbage collector/memory manager behaving strangely
On Mon, 17 Sep 2012 10:28:34 +0800, "Jadhav, Alok"
<email@example.com> declaimed the following in
> - 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...
last = ""
chunk = fin.read(500000) #read 1/2 MB max
#and attach to left-overs
if not chunk: #EOF, process any left overs
break #and exit
lines = (last + chunk).split("|\n")
last = lines[-1] #save "partial" line
for ln in lines[:-1]: #loop over rest
Wulfraed Dennis Lee Bieber AF6VN
|All times are GMT. The time now is 12:36 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.