unziping a file in python..

David Lyon david.lyon at preisshare.net
Mon Mar 2 17:29:26 EST 2009



On Mon, 02 Mar 2009 16:13:39 +0000, MRAB <google at mrabarnett.plus.com>
wrote:

> zf = zipfile.ZipFile('Archive.zip')
> for name in zf.namelist():
>      new_path = os.path.join(output_folder, name)
>      data = zf.read(name)
>      try:
>          open(new_path, 'wb').write(data)
>      except IOError:
>          # Create intermediate folders and try again
>          os.makedirs(os.path.dirname(new_path))
>          open(new_path, 'wb').write(data)
> --

Oh thanks for that...

Seems like the answer that i was looking for

Thank you very much...

(It's a 10 liner - I can live with that)

David




More information about the Python-list mailing list