Using the compression module

Benjamin Derstine bend at realeducation.com
Mon Apr 26 15:09:23 EDT 1999


Hello,
I'm looking for a simple example of how to use the compression module, gzip.
All I want to do is a make a compressed copy of a file.  From the gzip
documentation I see how to open a file for compression but I'm not sure what
to do with it after that. From the gzip documentation:

open (fileobj[, filename[, mode[, compresslevel]]])
     Returns a new GzipFile object on top of fileobj, which can be a regular
file, a StringIO object, or any object which simulates a file.

Okay, so I opened this file object :

f=open('/Audit.dbf','r')
test=gzip.GzipFile('Auditc','r','9',f)

So now how do I produce a compressed version of it?

Thanks,
Ben







More information about the Python-list mailing list