[Python] I get error that content isnot in my drive ,but i already uploaded and mount my...

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    import pandas as pd
    import zipfile

    # Open the zip file
    with zipfile.ZipFile("/content/drive/MyDrive/g collab dataset folder/odir dataset.zip", 'r') as zip_ref:
    # Get a list of all files in the archive
    file_list = zip_ref.namelist()
    # Print the list to inspect the file names and paths within the archive
    print(file_list)

    # Assuming the CSV file is named 'data.csv' and is located in the 'ODIR-5K' folder
    # Update csv_path with the actual name and path if it's different
    csv_path = '/content/odir dataset/ODIR-5K/ODIR-5K/data.xlsx'

    # Check if the file exists in the archive
    if csv_path in file_list:
    with zip_ref.open(csv_path) as csv_file:
    # Read the CSV file
    df = pd.read_csv(csv_file)
    else:
    print(f"Error: {csv_path} not found in the zip archive.")

    Continue reading...

Compartilhe esta Página