Hello, I am having some issues deploying my streamlit app via streamlit share. I have read in several datasets in my project, with the relevant directories, and its running fine locally. However, when I try and deploy it through my github report I am getting a FileNotFoundError and it can’t locate my CSV. Does anyone know how I can fix this? Is this an issue with my file structure?
Here is my github repo:
It is the ‘SelfScouting’ file, and within that I have all my 8 data folders and one folder called scripts, within the scripts I have my actual streamlit app called selfscoutapp.py.
Within the app I load in the csvs via the datafolder/data.csv.
Ex. GriffanSmithData/Griffan_Smith_Pitches.csv
This is how it is loaded in the selfscoutapp.py, and it runs perfectly locally, but when deploying it is having trouble locating the data files.
Thanks
Hi @v4_gadkari
The strings you are referencing are relative to the current working directory (cwd
) when you run the app locally. I’m not sure what the cwd
is on streamlit sharing, but you can overcome this issue with the pathlib
or os
modules for the standard library.
Below example using the pathlib
module as it has a more readable pattern.
from pathlib import Path
garret_burhenn_pitches_csv = Path(__file__).parents[1] / 'GarretBurhennData/Garret_Burhenn_Pitches.csv'
To explain above a little
Path(__file__).
will return the path of the respective file
.parents[1]
move up 2 directories where you stored the csv file
/
use divide symbol to chain the exact location.
The you can pass the path object to pandas and it will resolve the absolute path to load the data 
3 Likes
Thanks I will try this! I will let you know if it works
Thank you so much for your help @maarten-betman your solution worked and I will make sure to use this in the future!
1 Like
i am facing the same issue … everytime i upload a csv in github along with the py file and requirements. txt … it return that file is not found … i didn’t understand the above answer … anyone can help ? thank you
1 Like
Hi I am also having the same issue and I was wondering if you could help me? Thank you!