Issues with Reading in Dataset (FileNotFoundError)

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 :slight_smile:

4 Likes