Last active
March 27, 2023 21:19
-
-
Save bomzheg/9813c2626f621a13b620b01a98157942 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from typing import BinaryIO | |
from zipfile import Path as ZipPath | |
def load_results(zip_file: BinaryIO): | |
zip_path = ZipPath(zip_file) | |
for unpacked_file in zip_path.iterdir(): | |
if not unpacked_file.is_file(): | |
continue | |
if unpacked_file.name == "results.json": | |
with unpacked_file.open("r", encoding="utf8") as results_file: | |
print(type(results_file.read())) | |
continue | |
if unpacked_file.name == "image.jpg": | |
with unpacked_file.open("rb") as image: | |
print(type(image.read())) | |
if __name__ == '__main__': | |
with open("example.zip", "rb") as f: | |
load_results(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment