Where does to_csv file saved?

Hi,

I deployed an app where some user can create some data and that data will be available to other user. I used pd.to_csv when I was developing locally, and when deployed I can see that the csv file was not created (no where that I can see it, including in my github). However, the data is available when I close the browser and reopen the app.

The question is, where is this file located or saved? Will it be available forever for my app, or will it be deleted after a while? Below is the code snippet I used to create the csv file. Thank you!

Hi @nurakmal920207

Although I’ve not tried, I believe that by default the downloaded file should be saved in your current working directory (cwd).

You should be able to check the cwd path in your deployed app by adding the following code snippet to you app.py file:

import glob
import os

cwd = os.getcwd()
cwd

Let me know if that helps.

Best,
Charly

Hello @Charly_Wargnier,

I had a similar issue accessing files created by the app once it has been deployed on Streamlit share. I posted a question about it.

I have tried the approach you described but it didn’t work either. I have had to disable some functionality in my shared app. Maybe you can help check it out.

Cheers.

Hi @Charly_Wargnier ,

Thank you for your reply. I can find the file when running the app locally, however I couldn’t find it when running in Streamlit Sharing. Is there any way I can force Streamlit to push the file to Github each time a user make some changes? I am still very new to Github, in fact the reason I have a Github account was so that I can deploy the Streamlit app to the cloud.

Hope you can help. Thanks.

1 Like

Hi @nurakmal920207

To your question:

Is there any way I can force Streamlit to push the file to Github each time a user make some changes?

The answer is no, unless there’s an hack I’m unware of! :slightly_smiling_face:

If you save your files in your app’s root folder, your files would be saved in this location.

"/app/your_app_name"

You can always save them yourself, yet I don’t believe there’d be a way to push to GH.

I hope that helps?

Best,
Charly

Hi @Charly_Wargnier ,

Thank you so much. Although I couldn’t get my app to automatically push the file to Github, at least from your answer I know that it is not possible and I can stop looking for answer elsewhere.

Just to share, I decided to get around this problem by getting my app to email me the csv file, then I automate my laptop to download the csv file and push it to Github.

Although it is not the most elegant solution, but it does work in my case because I expect at most less than 10 changes each day, and it is not critical to have the file updated in real time so I can afford the file to be updated only when I open my laptop.

Cheers,
Akmal

Glad you’ve managed to find a workaround for this @nurakmal920207!

Happy Streamlitin’! :balloon::raised_hands:

Charly