[Tutor] removing file from zip archive.
Tim Golden
tim.golden at viacom-outdoor.co.uk
Wed Mar 29 10:38:22 CEST 2006
| How can we remove one file inside of a zip archive?
|
| I'm using this method:
|
| import zipfile
|
| ziparchive = zipfile.ZipFile('test.odt', 'r')
| xmldata = ziparchive.read('content.xml')
| ziparchive.close
(Warning: not my area of expertise, but...)
Your example *reads* one file from within a zip
archive, and is a perfectly good way of doing it
(indeed pretty much the only way of doing it).
Do I take it you want to end up with the same
archive but without that file?
If so, I don't believe it's possible as such.
What you'd have to do -- and this is almost
certainly what any front-end tool will do for
you behind-the-scenes -- is to copy the contents
of the archive to a temporary file omitting the
file(s) in question, and then to rename the
temporary file over the original.
TJG
________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
More information about the Tutor
mailing list