This code snippet is used to accept excel files. But when used it inside any function,The file is getting as ‘None type’ but when used globally,it is working properly
data = st.sidebar.file_uploader(“Choose an Excel file”, type=[‘xlsx’])
I want the file to work properly
Inside the function,File is treated as none type object
Thanks for reporting this error. We are actively looking into this and will update you soon.
I am not seeing the reported error – can you share a complete snippet showing the issue?
This works fine for me with streamlit 1.25.0
import streamlit as st
import pandas as pd
def get_data() -> pd.DataFrame | None:
data = st.sidebar.file_uploader("Choose an Excel file", type=["xlsx"])
if data is not None:
df = get_data()