Extracted files form zip corrupted
google at mrabarnett.plus.com
Thu Mar 26 13:31:12 CET 2009
Astley Le Jasper wrote:
> I want to batch extract files from a directory of zips. The thing is
> that the files are excel spreadsheets. I don't want to read them in
> python, just dump them as extracted files in another directory.
> However, when I do a test the excel file becomes corrupted. Any clues?
> import zipfile
> zf = zipfile.ZipFile('C:\Temp\mytest.zip')
> filename = 'spreadsheet.xls'
> data = zf.read(filename)
> uz_file = 'C:\Temp\' + filename
Be careful of backslashes in strings!
> f = open(uz_file, "w")
Open as a binary file:
f = open(uz_file, "wb")
More information about the Python-list