Skip to content

Instantly share code, notes, and snippets.

@icecore2
Last active February 1, 2023 12:11
Show Gist options
  • Save icecore2/348abe585c8978e93cd545cca158c353 to your computer and use it in GitHub Desktop.
Save icecore2/348abe585c8978e93cd545cca158c353 to your computer and use it in GitHub Desktop.
List of dicts from zip file list: {path: "", filename: ""}
"""
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