Can someone point out any errors I might have included in my code. I wanted to keep the code as simple as possible but it's failing with a memory error. Some of the compressed files do extract fine though...
import zipfile
import from os.path isdir, join, normpath, split
print "Unzipping data"
z = zipfile.ZipFile("C:\\Incoming\\MyZipFile.zip", 'r')
print z.namelist()
for each in z.namelist():
if not each.endswith('/'):
root, name = split(each)
print name
file(join("C:\\Incoming\\", name), 'wb').write(z.read(each))
z.close()
The actual error message generated is as follows:
Traceback (most recent call last):
File "C:\\Scripts\\Zip_import_test.py", line 30, in <module>
file(join("C:\\Incoming\\", name), 'wb').write(zip.read(each))
File "C:\\Python25\lib\zipfile.py, line 501, in read
bytes = dc.decompress(bytes)
Memory Error
Thanks for any suggestions. Frank Ogiamien