Context: My Flask app fetches data and stores it in "data" folder. Corresponding Python code:
data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data')
os.makedirs(data_dir, exist_ok=True)
print (f"data_dir is {data_dir}")
# Save the DataFrame to a CSV file in the 'data' directory
output_file = os.path.join(data_dir, f'stock_data_{ticker}.csv')
stock_data.to_csv(output_file)
I see Render is storing it at /opt/render/project/src/data/XYZ.csv
BUT it gives following error when trying to read from it
âError: File data\stock_data_VTEB.csv not found.â. Corresponding Pythong code-
ticker_filename = fâdata\stock_data_{ticker}.csvâ
data = pd.read_csv(ticker_filename )
Did you make sure to check your file path relative to the root of your project versus an absolute path? Also, backslashes are usually associated with Windows, so Iâm not sure why the error is showing backslashes.
You mentioned âUnable to access file I created locally.â Are these files uploaded to your GitHub repo (which isnât recommended, by the way) so theyâre deployed with your code on the filesystem? Or are you creating them at runtime? If itâs the latter, have you checked the filesystem via âShellâ or SSH to see if the files are in the expected location?