import io import zipfile def read_zip_file(archive_path: str, file_path: str): """ Read a file from a zip archive. Args: archive_path (str): The path to the zip archive. file_path (str): The path to the file inside the archive. Returns: io.BytesIO: The file as a BytesIO object. """ with zipfile.ZipFile(archive_path) as zip_file: file = zip_file.read(file_path) return io.BytesIO(file) if file else file