[Python] Unzipping Folders and Lox Files to Access Log Files Using Python

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am attempting to create a python script that can unzip a folder and unzip/extract data from the lox files located inside of the zipped folder so I can access log files within the lox files.

    import zipfile
    import os

    zip_path = r'C:\Users\Zachary\Zip\Conquest.zip'
    extract_to = r'C:\Users\Zachary\Zip'

    def Lox(zip_path, extract_to):
    with zipfile.ZipFile(zip_path, 'r') as zip_ref:
    zip_ref.extractall(extract_to)
    extracted_folder = os.path.join(extract_to, os.path.splitext(os.path.basename(zip_path))[0])
    for item in os.listdir(extracted_folder):
    if item.endswith(".lox"):
    lox_path = os.path.join(extracted_folder, item)
    with zipfile.ZipFile(lox_path, 'r') as lox_ref:
    lox_ref.extractall(extracted_folder)
    os.remove(lox_path)
    Lox(zip_path, extract_to)


    I received a PermissionError: [Errno 13] Permission denied and it was fixed after I included the zipped folder 'Conquest.zip' in zip_path. The lox file is extracted to my folder named "Zip" after I run the script, but the lox file is not unzipped to show the log files.

    Can someone help me please? What am I doing wrong?

    Continue reading...

Compartilhe esta Página