Hi All,
I am using dash_table to upload and show the datatable on callback.
But callback is not displaying table. Plz assist.
html.Div(dt1.DataTable(data=[{}], id=‘dftable’))
@app.callback(Output(‘dftable’, ‘data’),
[Input(‘upload-data’, ‘contents’),
Input(‘upload-data’, ‘filename’)])
def update_output(contents, filename):
df1 = parse_contents(contents, filename)
return df1.to_dict(‘rows’)
Thanks
@juhipandey4 Providing the data
prop is not enough to make the table display content. It also needs to be provided the columns
prop to know which fields to display on each row.
For example, a minimal columns configuration:
# -*- coding: utf-8 -*-
import dash
from dash_table import DataTable
import pandas as pd
url = 'https://github.com/plotly/datasets/raw/master/26k-consumer-complaints.csv'
rawDf = pd.read_csv(url)
df = rawDf.to_dict("rows"),
columns=[{"name": i, "id": i} for i in rawDf.columns]
app = dash.Dash()
app.scripts.config.serve_locally = True
app.layout = DataTable(
id='datatable',
data=rawDf[0:10].to_dict("rows"),
columns=columns
)
if __name__ == "__main__":
app.run_server(port=8053)