Decompressing gzip over FTP

S

SeanMon

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?

Thanks,
Sean
 
A

Albert Hopkins

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?

I tried to solve your problem with StringIO and .truncate(). I also
tried to solve it with us.pipe(), but was unsuccessful with either. The
problem is the gzip module uses .seek() which you can't do with pipes...

You could probably get away with just using the compress module (as zlib
does) but you will have to deal with handling the headers, footers, CRC
checks, etc. on your own.

The cheap alternative is to just have your script open a pipe to "gunzip
-c" and read/write from that pipe.

hth,
-a
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top