Plotly Dash Live Table

Guys,

I am new to plotly dash. I want to draw a table whose values (Rows) will automatically be updated after certain interval of time but i do not know how to use dash table experiments. The table is already saved as CSV file but i am somehow unable make it live. I just want a simple table whose values should be automatically updated after 5 minutes.

Can some one guide me in the right direction what should i do

Your help will be highly appreciated. !

I am trying the following approach.


                          import dash
        import pandas as pd
        from pandas import Series, DataFrame
        import dash
        from dash.dependencies import Input, Output, Event
        import dash_core_components as dcc
        import dash_html_components as html
        import dash_table_experiments as dtable
        app=dash.Dash()

        def TP_Sort():
            address = 'E:/Dats Science/POWER BI LAB DATA/PS CORE KPIS/Excel Sheets/Throughput.xlsx'
            TP = pd.read_excel(address)
            TP1=TP.head()
            Current_Interval.to_csv('TP1.csv', index=False)
            return
        app.layout = html.Div([
            html.H1('Data Throughput Dashboard-NOC NPM Core'),
            dcc.Interval(id='graph-update',interval=240000),
            dtable.DataTable(id='my-table',
                             rows=[{}],
                             row_selectable=False,
                             filterable=True,
                             sortable=False,
                             editable=False)
        ])
        @app.callback(
                     dash.dependencies.Output('my-table','row_update'),
                     events=[dash.dependencies.Event('graph-update', 'interval')])
        def update_table(maxrows=4):
            TP_Sort()
            TP_Table1='C:/Users/muzamal.pervez/Desktop/Python Scripts/TP1.csv'
            TP_Table2=pd.read_csv(TP_Table1)
            return TP_Table2.to_dict('records')    


        if __name__ == '__main__':
            app.run_server(debug=False)

BR, Rana

1 Like

Change the update_table Output to Output('my-table', 'rows'), remove the events key, and add Input(‘graph-update’, ‘n_intervals’)

Example:

@app.callback(Output('my-table', 'rows'), [Input('graph-update', 'n_intervals')])
def update_table(n_intervals):
    ...

Thanks a lot Phillipe,

I really appreciate your time and input. Its working now !

`

1 Like