unzip problem

Ethan Furman ethan at stoneleaf.us
Fri Jun 24 14:55:52 EDT 2011


Ahmed, Shakir wrote:
> 
> Thanks for your help and really appreciate your time.
> 
> I changed the code as you mentioned and here it is:
> 
> 
> fn = open('T:\\applications\\tst\\py\\Zip_Process\\Zip\\myzip.zip',
> 'rb')
> z = zipfile.ZipFile(fn)
> for name in z.namelist():

       data = z.read(name)

>     ptr = 0
>     size = len(name)  # change this back to data
                 ^- No.  You need the size of the data read in from the 
zipfile for that name, not the length of the name.  Sorry for the omission.

>     print size
>     print ptr
>     while ptr < size:
>         
>         fn.write(name[ptr:ptr+CHUNK_SIZE]) # change name to data
>         ptr += CHUNK_SIZE
> 
> fn.close()

~Ethan~



More information about the Python-list mailing list