Possible to dynamically write to a file?

Hi! This is a bit abstract but I wanted to see if the community had any input as to whether this is doable.

I’ve made a flexible Dash app that allows you to upload a csv and create x graphs and choose from a checklist which traces to show on each one. My goal is to add a “save/load preset” feature where I can save the current settings of the page (how many graphs, which traces are on each one) to a downloadable config file (separate from the uploaded csv) that I can later upload along with the csv to quickly display those same traces and graphs. I’m not totally sure if that’s possible, but we will see.

For context: my *very* half-baked idea is to give each important callback (like where I update the graphs from the checklist) an additional output to a dcc.Store component that will contain data about what has been created, and when I click some “download preset” button, it combines all of the dcc.Store data and writes it into the file.

My first problem is figuring out how to write to a file with Dash. I’m not super familiar with Dash, but I’ve been googling and I haven’t seen anything about dynamically writing and saving to a file–all the download examples I have seen (like on the dash dcc.Download page) just create a file with a pre-determined string.

Is it possible to have more flexibility in this–ie, writing the ‘data’ of a dcc.Store component into the file? And is it possible to combine the data from multiple inputs? The dict property of the dcc.Download component is really confusing me in terms of this.

Hi @weez and welcome to the Dash Community.

I think the best way is to get all the info you want in a Pandas DataFrame and then save it in a csv file like this:


You can use any input for your callback, like dcc.Store ‘data’ create the table with all the information in Pandas and later you can read the file and use the information as any other csv file.

1 Like

Thank you for this! :slight_smile: