Upload DataFrame and store the data for use in Callback

Hey @martin2097 and @AnnMarieW , I want to store dataframe from the dcc.upload section as given in the example of Displaying Uploaded Spreadsheet Contents

How can I store this data and use it in some other callbacks?


dcc.Store is what you are looking for. Store | Dash for Python Documentation | Plotly Check the example Share Data Between Callbacks :slight_smile:

Hi Martin,
Can you help me out with the coding part of dcc.store callback for storing the data from dcc.Upload as given in the example of Displaying Uploaded Spreadsheet content

I don’t understand how to call the dcc.store callback once the user has uploaded his/her csv or xlx file to store the df data ?

I found an example of what you are asking for here: Upload CSV with dcc.Upload to store using dcc.Store and then displaying table - #3 by 3d65

Check it out, what you are asking for is kinda standard formula: Upload → Store → Table, it is the main reason why I try to pointo you in the right direction through multiple pages of documentation and examples on the forum :slight_smile:

What is the best way to store a large file for use by later callbacks in Dash?

I am building a dashboard where you upload a dataframe and then subsequent steps are performed based on successive inputs, and the data files can be large(possibly 100s of MBs). After the initial cleaning and size reduction step(where I bring it down by 50%), I have to store the file so that the later callbacks can use it. But using dcc.store of a df.to_json doesn’t seem to be working, as the stored version is often bigger than the original file itself.

I am not sure if there is a better way to do this, as all the data is definitely needed for the later parts, and since the data is uploaded and not given from the beginning, I can’t use a global variable(anyway, that’s frowned upon).

Thank you Martin for the fast response and I appreciate for the help.
Thanks once again :smile:

Have you tried the ServersideOutputTransform?

1 Like