Last active
February 1, 2023 12:11
-
-
Save icecore2/348abe585c8978e93cd545cca158c353 to your computer and use it in GitHub Desktop.
List of dicts from zip file list: {path: "", filename: ""}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This gist will create list of dictionaries. | |
""" | |
import pyzipper | |
def test(): | |
with pyzipper.PyZipFile(file="/home/dima/Desktop/test.zip") as fz: | |
files = fz.filelist | |
list = [] | |
for item in files: | |
file_split = item.filename.split("/") | |
if not file_split[0].endswith("/"): | |
file_name_dict = {'path': file_split[0], 'filename': file_split[-1]} | |
list.append(file_name_dict) | |
return list | |
if __name__ == "__main__": | |
print(test()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment