dcc.store for live-dating data table DASH

I implemented a live-update feature to the add column function based on the documentation on editable DataTable https://dash.plotly.com/datatable/editable such that a new column is added to the datatable when the CSV file is updated. I've got the callback working and I need to save the state of the datatable in a dcc.store, which was kindly recommended to me, so that I store the current number of columns, and add only the newly updated columns based on the new CSV data. I need to do this because users input data the table, and if I live update the whole table the data is lost. I do not know if I can access the user input data in dcc.store, so instead I only wish to add on new columns to the datatable thereby preserving using input.

My question: is there a way I can assess the current number of columns in an existing data table?

app.layout = html.Div([
                    'name': 'Parameter',
                    'id': 'column1',
                    'deletable': True,
                    'renamable': True
                    {'column1': j}
                    for j in table_contents

@app.callback(Output('mystore', 'data'),
              Input('graph-update', 'n_intervals'),
              State('editing-columns', 'data'))
def serve_layout(n,data):
   data2 = json.dumps(data)

    return data2


[{"column1": "Propofol/Remi @ 6.5 ug/ml", "08:47": "150-180->"}, {"column1": "Infusion", "09:41": "12"}, {"column1": "Fentanyl (ug)"}, {"column1": "Versed (mg)", "09:20": "23"}, {"column1": "Propofol (mg)", "08:47": "2"}, {"column1": "Remi (ug)", "08:47": "20"}, {"column1": "Ketorolac (mg)", "08:47": "15"}, {"column1": "Dex (mg)", "09:32": "12"}, {"column1": "Roc (mg)"}, {"column1": "Neo/Gly (mg/mg)"}]

I can see data cell input but although the table has many columns I don't get access to that. enter image description here

Read more here: https://stackoverflow.com/questions/66326060/dcc-store-for-live-dating-data-table-dash

Content Attribution

This content was originally published by Robert Marciniak at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: