removing the header from a gzip'd string

Fredrik Lundh fredrik at pythonware.com
Thu Dec 21 16:32:05 EST 2006


Rajarshi wrote:

> Hi, I have some code that takes a string and obtains a compressed
> version using zlib.compress
> 
> Does anybody know how I can remove the header portion of the compressed
> bytes, such that I only have the compressed data remaining?

what makes you think there's a "header portion" in the data you get
from zlib.compress ?  it's just a continuous stream of bits, all of 
which are needed by the decoder.

 > (Obviously I do not intend to perform the decompression!)

oh.  in that case, this should be good enough:

     data[random.randint(0,len(data)):]

</F>




More information about the Python-list mailing list