File size: 469 Bytes
0123dbc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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