-
Notifications
You must be signed in to change notification settings - Fork 3
/
README
17 lines (11 loc) · 805 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
improvement of zipfile for a particular usecase,
namely when you need a known set of files from a zip containing a lot more files
The problem that's solved by this improvement
http://stackoverflow.com/questions/37141286/efficiently-read-one-file-from-a-zip-containing-a-lot-of-files-in-python
Note: It's quite hacky right now and much of the functionality is simply not tested since the change. function that helps you that is defined in zipfile.py
def extractFilesFromZip(zip:str, filenamelist:list):
setlist = set(filenamelist)
with ZipFile(zip, to_extract=setlist, mode='r') as myzip:
return [myzip.open(filename).read() for filename in setlist]
This code comes without any guarantees:
- I copied the zipfile code from pypy and edited to for my specific use case