tags:

views:

74

answers:

2

I have a path to a zip file. I don't know how to

  • retrieve the file from the hard drive or
  • open that zip file. Does anyone know?

The zip file is a zip file, but it's really a .epub file.

+1  A: 

You don't need anything Django specific, just use the Python standard library, with the class ZipFile(file_name[, mode[, compression[, allowZip64]]]) from the zipfile package.

voyager
+2  A: 

http://docs.python.org/library/zipfile.html

>>> import zipfile
>>> path = "example/path.epub"
>>> epub = zipfile.ZipFile(open(path))
>>> epub.namelist()
 ['some_file.txt']
>>> file = epub.open('some_file.txt')
>>> file.read()
mbarkhau
Installed Python 2.6.4. Now all of the code above works. Thanks.
Alex