So, I am wondering if anyone has successfully been able to load a dataframe/file from your local machine to a web app?
I built this application that takes in a dataset/csv file from my C: drive. I have a selectbox on the sidebar that selects the file to be loaded and then it performs some EDA. I works as intended on my machine but when I deploy it on heroku-- it is not able to access the files.
Here’s a screenshot of the app when the file is loaded on my localhost:
I printed the CWD for troubleshooting purposes and it looks good on my machine.
This is what I get when I run it on heroku:
As you can see, the app is not able to find the local directory that I am providing.
The code to retrieve the file from my C: drive is as follows (#ignore commented out lines as I was using them to try to figure out what the problem was)
st.write(os.getcwd()) #os.chdir(r"C:\Users\us1145\Desktop\DataFrames/") #home = os.environ #st.write(home) #st.write(os.getcwd()) path_to_file = (r"C:\Users\us1145\Desktop\DataFrames/") file_list = [f for f in listdir(path_to_file) if isfile(join(path_to_file, f))] file_select = st.sidebar.selectbox("Select a file", file_list) st.sidebar.title("Load Dataset") if st.sidebar.button("Click to load data"): with st.spinner("Loading "+ file_select + " ..."): time.sleep(20) st.success("File loaded!")
Any help would be greatly appreciated!