![]() |
Zipping and Unzipping files
Is there a simple way to zip and unzip files?
I'm looking for something along the lines of: zfile = zipfile(r'c:\somefile.zip') zfile.extract(r'c:\somefiles') I've looked at the documentation for zlib and zipfile, and they seem pretty comprehensive, but also extremely low level. If needed, I can probably make a workable component from them, but I was wondering if there is one already written that I'm just missing. -- Doug Tolton (format t "~a@~a~a.~a" "dtolton" "ya" "hoo" "com") |
Re: Zipping and Unzipping files
Doug Tolton wrote:
> > Is there a simple way to zip and unzip files? > > I'm looking for something along the lines of: > > zfile = zipfile(r'c:\somefile.zip') > zfile.extract(r'c:\somefiles') > > I've looked at the documentation for zlib and zipfile, and they seem > pretty comprehensive, but also extremely low level. If needed, I can > probably make a workable component from them, but I was wondering if > there is one already written that I'm just missing. Probably not, since it's likely to require slight differences in each application. Try this (untested): import os, zipfile def extract(self, todir=''): for name in self.namelist(): f = open(os.path.join(todir, name), 'wb') f.write(self.read(name)) f.close() zipfile.ZipFile.extract = extract Now you should be able to execute the two example lines you showed above... -Peter |
| All times are GMT. The time now is 02:57 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.