i have a dataframe in excel file. I want to load that to a variable using file uploader. When i read the o/p from file uploder, looks like its byte i.o and when i use pd.DataFrame on top of it. It does not give intended result. Though if i use st.table(), i am able to see results as table
Hey @karthico, Welcome to the forums!
Try this after running
pip install xlrd
import streamlit as st import pandas as pd uploaded_file = st.file_uploader("Choose a XLSX file", type="xlsx") if uploaded_file: df = pd.read_excel(uploaded_file) st.dataframe(df) st.table(df)
hey buddy, thanks a lot this works. Also any idea like what are the file types we can upload.
Hey @karthico - you should be able to upload files of any type (though you can limit which file extensions the file uploader will accept with the optional
st.file_uploader widget returns each uploaded file as either a string (if the file is just text) or a
BytesIO binary blob (for all other files). In the latter case, you’ll need to have code that can work with the file’s binary format, but you’re not limited in what you can do with it.