Decompressing gzip over FTP

SeanMon smono927 at gmail.com
Sat Aug 22 03:51:47 CEST 2009


On Aug 21, 9:40 pm, Christian Heimes <li... at cheimes.de> wrote:
> SeanMon schrieb:
>
> > Is there a way to decompress a large (2GB) gzipped file being
> > retrieved over FTP on the fly?
>
> > I'm using ftplib.FTP to open a connection to a remote server, and I
> > have had no success connecting retrbinary to gzip without using an
> > intermediate file.
>
> > Is there any way to get a file-like object describing the remote file,
> > or a way to utilize gzip's decompression without providing it a file-
> > like object?
>
> gzip is really just a file format. In order to work with compressed
> streams you should use the low level zlib module.
>
> http://docs.python.org/library/zlib.html#module-zlib
>
> Have fun!
>
> Christian

Unfortunately, the file on the server is a gzip file, so I cannot
simply pipe the contents into a zlib.decompressobj (which does have
the ability to decompress in chunks, as I wish gzip did!).

Thanks,
Sean



More information about the Python-list mailing list