I read through the zipfile modules docs, but couldn't understand how to unzip a file, only zip a file. What is the simplest way to unzip all the contents of a zip file into the same directory?
Yes, and its 150 lines and overly complicated for what I am doing. I was hoping for maybe 5 lines max.
Zonda333
2010-08-10 16:23:07
+4
A:
zip_ref = zipfile.ZipFile(path_to_zip_file, 'r')
zip_ref.extractall(directory_to_extract_to)
zip_ref.close()
Thats pretty much it.!
Rahul
2010-08-10 16:23:27
A:
Use the extractall
method, if you're using Python 2.6+
zip = ZipFile('file.zip')
zip.extractall()
Dan Breen
2010-08-10 16:23:50