Retrieve data from gz file on FTP server without writing it locally
I would like to retrieve the data inside a compressed gz file stored on an FTP server, without writing the file to the local archive. At the moment I have done from ftplib import FTP import gzip ftp = FTP('ftp.server.com') ftp.login() ftp.cwd('/a/folder/') fileName = 'aFile.gz' localfile = open(fileName,'wb') ftp.retrbinary('RETR '+fileName, localfile.write, 1024) f = gzip.open(localfile,'rb') data = f.read() This, however, writes the file "localfile" on the current storage. I tried to change this in from ftplib import FTP import zlib ftp = FTP('ftp.server.com') ftp.login() ftp.cwd('/a/folder/