8

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.

Please help!

Can some one guide me in the right direction what should i do Your help will be highly appreciated. Following is the code.

import dash
import pandas as pd
from pandas import Series, DataFrame
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)

I am trying the above approach. Please correct me where i am wrong as the output is error loading dependencies.

BR Rana

4
  • Can you create a minimal working example? Commented Jul 30, 2018 at 15:45
  • 1
    Updated the shortened code. Commented Jul 30, 2018 at 16:37
  • Or can you please guide me how can i make a table in dash whose rows will be automatically updated after the values are changed in parent file? Commented Jul 30, 2018 at 16:41
  • 1
    For future searchers, a bunch of the dash_table.DataTable keywords have changed from the experimental version (e.g. filterable->filtering, sortable->sorting, the built in documentation should be helpful with this). Also, all these functions are now in the main dash_table module. Commented Mar 23, 2019 at 12:10

1 Answer 1

7

Your callback is wrong.

It should be:

@app.callback(Output('my-table', 'rows'), [Input('graph-update', 'n_intervals')])
def update_table(n, maxrows=4):
    # We're now in interval *n*
    # Your code
    return TP_Table2.to_dict('records')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.