Streamlit File Saving onto Desktop

Hi! I am creating a program where I am taking two files that are uploaded and manipulating them using excel with pandas. Then, with the new file that is created I want to save it onto the user’s desktop. When I tested the program it worked on my local branch, however when I go to deploy the app, this doesn’t work. I have tried to look for solutions but every solution I find only seems to create the same issue.

Hi @Hannah_Elizabeth_Lex,

Thank you for sharing your question with the community!

Your post is missing a code snippet and a link to your app’s GitHub repo. Please check out our guidelines on how to post an effective question here and update your post to help the community answer your question.

Also, do you have a download button for the user to download the files once they’re ready?

So Sorry about that. I am programming in Python. I currently don’t have a download button since I want to automatically have the file sent to the users desktop.

Github Repo:

Code Snippet:“~/Desktop/Site Automation Calculation.xlsx”))
#f’C:\Users\{user_input}\Desktop\Site Automation Calculation.xlsx’)
wb = Workbook(“Site Automation Calculation.xlsx”)

With streamlit your code may be rerunning more times than you expect. For me, the easiest way was with a button like:

df = pd.DataFrame(st.session_state['wordlist_unique'], columns=['words'])
output_csv = df.to_csv(index=False).encode('utf-8')
st.download_button('Download CSV', output_csv, file_name="vocabulary.csv", mime='text/csv')

Thanks Shawn! I was able to get the button to work. However, now I am having the problem that using pandas to write to cells. However, when I go to download the xslx sheet, it is not producing any of that data. Is Excel formulas not supposed to occur when using streamlit.

Looks like pandas supports this but you may need to read a bit to get exactly what you want…

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.