Hi All,
I have a csv which gets appended with new data every couple of seconds.
I would like to have a data table based on this csv so that the data table is always showing the newest data first in the csv.
So far I was only able to have the new data in the data table by quitting from the app and rerunning the application. Any idea how it can be done automatically? Below is my code as it is currently:
import dash
import dash_table
import pandas as pd
app = dash.Dash(name)
df = pd.read_csv(‘C:/Users/AZT/Documents/csvfile20190903.csv’, encoding=‘cp1250’)
df = df.reindex(index=df.index[::-1])
def serve_layout():
return dash_table.DataTable(
data=df.to_dict(‘records’),
columns=[
{‘name’: i, ‘id’: i} for i in df.columns
],
style_data_conditional=[
{
‘if’: {
‘column_id’: ‘Attribute6’,
‘filter_query’: ‘{Attribute6} = 2’,
},
‘backgroundColor’: ‘pink’
},
{
‘if’: {
‘column_id’: ‘Attribute6’,
‘filter_query’: ‘{Attribute6} < 2’,
},
‘backgroundColor’: ‘lightblue’
},
]
)
app.layout = serve_layout
if name == ‘main’:
app.run_server(debug=True)
Thank you in advance!