Hello everyone,
I’m building a web page using Streamlit to display Excel and CSV data in both chart and numeric formats.
I’ve implemented most of the code, and I placed the data files in my local folder, but the data upload isn’t working — it seems like Streamlit isn’t properly connecting to Excel.
I’d like to ask for advice from people around the world on how to fix this issue.
I’ll share my code and files below for reference.
“Could it be an issue related to absolute vs. relative paths?”
you need help with “file upload”, but the sample code show “file download”
Here is a sample code that works for an excel file upload.
import streamlit as st
from io import BytesIO
#the begin of the specific function
def import_repartition_mensuelle(my_file):
my_byteio_file = BytesIO(my_file)
df = pd.read_excel(my_byteio_file,skiprows=5)
df = df.drop(df.columns[[ 5, 6, 7, 8, 11]], axis=1)
#.......etc...
def upload_repartition():
uploaded_files1 = st.file_uploader("Choisissez le fichier de répartition", accept_multiple_files=True, type={"xlsx"}, key="uploaded_file")
for uploaded_file in uploaded_files1:
bytes_data = uploaded_file.read()
st.write("Traitement de :", uploaded_file.name)
with st.spinner(text="En cours..."):
with open("uploaded_file.name", "wb") as binary_file:
#specific function with bytes_data as argument
import_repartition_mensuelle(bytes_data)
upload_repartition()