gzipping several files

Byrom, R (Rob) R.Byrom at rl.ac.uk
Mon Dec 1 11:40:31 EST 2003


thanks Gerrit, 

I should of been a bit more specific, I actually did intent to use *.gz
format and not *.zip (a faux-pas on my behalf). I've worked around the
problem for the moment by just using the commands.getstatusoutput() to
execute the linux gzip command. Obviously Im not worried about portability! 

-----Original Message-----
From: Gerrit Holl [mailto:gerrit at nl.linux.org]
Sent: Monday, December 01, 2003 3:31 PM
To: Byrom, R (Rob) 
Cc: python-list at python.org
Subject: Re: gzipping several files


Byrom, R (Rob)  wrote:
> Does anyone know how to read-in several files and then batch all together
> into a *.zip format? I've looked at the gzip module but I'm not sure how
to
> use this with several files. Any help gratefully received!

The gzip module is about gzip, not about zip. Zip is different from
gzip: zip is both an archiver and a compressor: it bundles several files
into 1 file, *and* compresses them. In Unix, there are two different
protocols for that: archiving is done with tar (tarfile[0]), compressing
is done with gzip or bzip[1]. If you want to create a zip file, you may
use the zipfile module ;)[2]. A good place to look for a module if you
can't find it is the standard library documentation[3]. It is very
useful!

yours,
Gerrit.

[0] http://www.python.org/dev/doc/devel/lib/module-tarfile.html
[1] http://www.python.org/dev/doc/devel/lib/module-gzip.html, 
    http://www.python.org/dev/doc/devel/lib/module-bz2.html
[2] http://www.python.org/dev/doc/devel/lib/module-zipfile.html
[3] http://www.python.org/dev/doc/devel/modindex.html

-- 
273. If any one hire a day laborer, he shall pay him from the New Year
until the fifth month (April to August, when days are long and the work
hard) six gerahs in money per day; from the sixth month to the end of the
year he shall give him five gerahs per day.
          -- 1780 BC, Hammurabi, Code of Law
-- 
Asperger's Syndrome - a personal approach:
	http://people.nl.linux.org/~gerrit/english/





More information about the Python-list mailing list