Backslashes in files paths will not work on Streamlit Cloud. Your file path may work on a local, Windows environment using backslashes, but Streamlit Cloud is Debian. That is a key part of “OS-agnostic.”
Another way to do what @arnaud said is to use:
./data/datasethospital.xlsx for your path. Both Windows and Streamlit Cloud will understand the forward slashes.
As @Goyo has pointed out, there’s a difference between forward and backward slashes. I can get Streamlit to read file paths correctly with either one in my local environment, but it requires forward slashes in the cloud environment.
import streamlit as st
import pandas as pd
try:
st.write('Trying with back slashes')
st.dataframe(pd.read_csv(r'.\\files\\test.csv'))
except:
st.write('It didn\'t work with back slashes.')
try:
st.write('Trying with forward slashes')
st.dataf…
1 Like