Проблемы с флаком при загрузке файла и открытии с помощью пандыPython

Программы на Python
Гость
Проблемы с флаком при загрузке файла и открытии с помощью панды

Сообщение Гость »


У меня есть простое приложение Flask. Мне нужно загрузить файл Excel, поработать с ним, а затем сохранить его на диске. Для этой цели у меня есть этот код.

Код: Выделить всё

app = Flask(__name__)

FILE_PATH = 'files'
app.config['UPLOAD_FOLDER'] = FILE_PATH

@app.post("/upload")
def upload():
# Read the File using Flask request
file = request.files['file']

filename = secure_filename(file.filename)

# Open with panda and do some work.This work don't affect so is no there
input_df = pd.read_excel(io.BytesIO(file.read()), 'sheetName', header=None)

# Save the file
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))

I have no errors on flask console, but when i go to upload folder i see that uploaded excel file have 0KB and i can't open.
If i don't open with Panda, that is deleting input_df = pd.read_excel(excel_path, 'sheetName', header=None) from the code, all work fine. The uploaded excel file was well.
So my cuestion is what i'm doing wrongo
with panda? I need to close after read_excel or something like that? I'm reading flask and pandas documentation but didn't see nothing relted.
Thanks


Источник: https://stackoverflow.com/questions/781 ... with-panda

Вернуться в «Python»