File upload

I’m trying to create an uploader file that works as input for all my tabs.
please help me how to do it.

sample code:
selected = option_menu(None, [“Home”, “Upload”, “Tasks”, ‘Settings’],
icons=[‘house’, ‘cloud-upload’, “list-task”, ‘gear’],
menu_icon=“cast”, default_index=0, orientation=“horizontal”)
selected

if selected == “Home”:
st.title(f"You have selected {selected}“)
if selected == “Upload”:
st.title(f"You have selected {selected}”)
with st.header(‘1. Upload your CSV data’):
uploaded_file = st.file_uploader(“Upload your input file”, type=[‘csv’])
if selected == “Tasks”:
#st.title(f"You have selected {selected}")
### Read csv
iris = pd.read_table(uploaded_file , sep=‘,’, header=0)

Try this:

  1. Assign an explicit key to the file uploader.
    st.file_uploader("Upload your input file", type=["csv"], key="uploaded_file")

  2. Use session_state["uploaded_file"] to access the uploaded file where you need it.
    iris = pd.read_table(st.session_state["uploaded_file"] , sep=",", header=0)

I never tried this with a file uploader but it works with other widgets.

wonderful Goyo this worked thanks