ZLIB decompressing only portion of data

mkx at excite.com mkx at excite.com
Wed Feb 21 17:24:26 CET 2001

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

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

This methodology still only returns the first segment of uncompressed

So far, only the following works, returning about 12K of uncompressed
data, before returning an Error -3 while decompressing: unknown
compression method.


import zlib

fd=open('d:/temp/zlb/snippets.zlb', 'rb' )

dco = zlib.decompressobj()
str = dco.decompress(fd.read(16384))

while dco.unused_data:
    ustr = dco.unused_data
    dco=zlib.decompressobj()	# Having to recreate the dco object
				# each time, otherwise further data 
				# not returned

More information about the Python-list mailing list