ZLIB decompressing only portion of data

mkx at excite.com mkx at excite.com
Wed Feb 21 11:03:06 EST 2001


On Wed, 21 Feb 2001 06:23:14 GMT, "Fredrik Lundh"
<fredrik at pythonware.com> wrote:

>mkx at excite.com wrote:
>> Of course, there is a better way to implement my test script (see
>> below), but I still get the same results. The input sample is 9,859
>> bytes long, where the string returned by the decompress method is only
>> 546 bytes in length.
>
>what's wrong with using "open" like everyone else?

Nothing! Python is new to me, and sometimes I take the long way
around. In this case, I tried "open", but in the process of
determining that the file needed to be opened as Binary, I found my
self at os.open, instead of open(,"rb"). 

<...>

>str = dco.decompress(file.read(16384))
>str = str + dco.flush() # get rest of data

Ah...Through trial and error, I was only successful (partially) by
using dco.unused_data, but then I had to recreate the decompress
object with each iteration when .unusued_data was present.

It appears that the .decompress method is only decompressing the first
"segment" of the data. At this point I am unsure what delimits the
segments.

>for more info on decompress/flush, see the docs (under
>"decompression objects"):
>
>http://www.python.org/doc/current/lib/module-zlib.html
>
>(and of course, if the files are smaller than a couple of megabytes
>uncompressed, it's better to use zlib.decompress...)

That is where I started, but then I ran in to the problem with only
the first segment of the data being uncompressed. Using the decompress
object is the only thing I have working so far.




More information about the Python-list mailing list