Carl Banks wrote:
Waguy wrote: I am new to python and want to create a process to unzip large numbers of
zip files I get from a SOAP application. The files all have a ZIP extention
and can be unzipped using WinZip....
Can anyone help with this? ...
Another possibility is this: From the documentation:
"This module does not currently handle ZIP files which have appended
comments, or multi-disk ZIP files."
One thing I've noticed is that, when downloading zip files from a
service of some sort, they often seem to have appended comments.
("This file downloaded from www.extremezipfiles.com, blah blah blah.")
Based on the file Waguy originally sent, you could try using this:
import zipfile, cStringIO
def getzip(filename, ignoreable=100):
try:
return zipfile.ZipFile(filename)
except zipfile.BadZipfile:
original = open(filename, 'rb')
try:
data = original.read()
finally:
original.close()
position = data.rindex(zipfile.stringEndArchive,
-(22 + ignoreable), -20)
coredata = cStringIO.StringIO(data[: 22 + position])
return zipfile.ZipFile(coredata)
--Scott David Daniels
sc***********@acm.org