[Python] 'SpooledTemporaryFile' object has no attribute 'seekable' | python

Discussão em 'Python' iniciado por Stack, Abril 29, 2025.

  1. Stack

    Stack Membro Participativo

    i have been trying to call one API but having issues to read excel file and getting this errors

    ` def insert_secon_file(self, file):

    filename = file.filename if hasattr(file, "filename") else file
    if not filename.endswith(".xlsx"):
    raise ValueError("Only .xlsx files are supported.")

    if hasattr(file, 'seekable') and file.seekable():
    file.seek(0)
    # Load the .xlsx file
    workbook = openpyxl.load_workbook(file.file if hasattr(file, "file") else file)
    # Get the last workbook
    last_sheet = workbook.worksheets[-1]
    # Read the content of the last workbook
    data = []
    for row in last_sheet.iter_rows(values_only=True):
    data.append(row)

    # Insert data into the database
    return self._insert_data_into_table(data)`


    INFO: Application startup complete. 'SpooledTemporaryFile' object has no attribute 'seekable' INFO: 127.0.0.1:34768 - "POST /api/v1/secon/upload_secon HTTP/1.1" 500 Internal Server Error

    Continue reading...

Compartilhe esta Página