I am creating an app that uses requests to create a CSV file, the response will return a URL to download the file generated.
How can I automatically download the file into the User’s computer?
The idea is that they will upload to streamlit a file that contains the data of the items they want to generate a report to. A loop will take this info for each row in the file and generate the reports. For each loop iteration, the report has to be downloaded. since several reports will be generated, I want to have the report downloaded automatically avoiding the user to click a download button each iteration.
Is the app available publicly so we can maybe take a look at it? It’s hard to say without additional information, but I’m curious about the process. Can the files be appended or merged and still allow you to accomplish your goal?
I did come across this conversation below that sounds similar to this scenario and wanted to share in the event it will be helpful. Best of luck and have a good weekend.
Perhaps you can embed all widgets inside a st.form and upon clicking on the Submit button, all necessary processing are performed and culminating with a file download. As for having the file download occur without explicitly using the st.download_button, I think you can get some inspiration from the code snippet provided at this link: Automatic Download / Select and Download File with Single Button Click - #4 by snehankekre
Thank you all, I figured out by creating a list and saving the csv files on it, then iterating the list and saving a zip file. Finally I can use the st.download_button() to download the zip file that contains all the csv files.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.