469,306 Members | 1,627 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Extracting Zip Files

I've been zipping up files for months with zipfile, but today I was asked to
extract the contents of a zip file and was sure there would be an "extract"
method...but there's not one that I can find! Am I just missing something??
I found a module, unzip.py, on Parnassus, but it doesn't work. Does anyone
have a way for me to extract files? Thanks!
Greg Lindstrom (501) 975-4859
NovaSys Health gr************@novasyshealth.com

"We are the music makers, and we are the dreamers of dreams" W.W.

Jul 18 '05 #1
2 1566
Hi !

You can try :

http://mclaveau.com/ress/python/zipmci.htm
@-salutations
--
Michel Claveau

Jul 18 '05 #2
Greg Lindstrom <gr************@novasyshealth.com> wrote:
I've been zipping up files for months with zipfile, but today I was asked to
extract the contents of a zip file and was sure there would be an "extract"
method...but there's not one that I can find! Am I just missing something??
I found a module, unzip.py, on Parnassus, but it doesn't work. Does anyone
have a way for me to extract files? Thanks!


First, instantiate z=zipfile.ZipFile('whatever.zip'). Now, z.namelist()
gives you a list of all the names in 'whatever.zip', and for each of
these names z.read(name) gives you all the bytes. Net of subdirectory
issues, therefore, something like (note: untested!):

for n in z.namelist():
open(n, 'w').write(z.read(n))

should extract all files to the current directory.
Alex
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Nazgul | last post: by
reply views Thread by Nadav | last post: by
3 posts views Thread by wenz | last post: by
reply views Thread by k_nil | last post: by
2 posts views Thread by bjm | last post: by
4 posts views Thread by Ant | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.