zlib problems with Python 2.0
reqhye72zux at mailexpire.com
Mon Aug 20 02:56:41 CEST 2001
Peter van der Kamp wrote:
> My script does the following.
> Read chunks of text from a text file (I have good reasons not to
> compress the complete file, so I won't explain that here).
Let me guess: you're trying to make a text search machine, right? Don't
make the chunks too small, though, the compression ratio really suffers
in that case.
> z = open("d:\\z.dat", "w")
Shouldn't that be "wb"?
> z = open("d:\\z.dat", "r")
And this "rb", perhaps?
That could be the reason tell/seek doesn't work as expected. If that
doesn't cure is, write a distictive marker (a few bytes) in the file
before each chunk, and check if it's at the expected position _before_
decompressing. You might even want to leave it in the finished code,
it's a good indicator of file corruption.
HTH, Robert Amesz
More information about the Python-list