I try to create a simple dash_table but its show up nothing. I load a dataframe and uses this code:
html.Div([dash_table.DataTable(
id='datatable',
data=df.to_dict('row'),
row_selectable=False,
filtering=True,
sorting=True,
editable=False,
#style_as_list_view=True,
style_table={'height': '300','overflowX': 'scroll'},
n_fixed_rows=1,
style_header={'backgroundColor': 'rgb(30, 30, 30)'},
style_cell={
'backgroundColor': 'rgb(50, 50, 50)',
'color': 'white'
},
)]
In a callback upload function which is also connected with a graph I do this:
@app.callback(
Output('datatable', 'data')
,#Output('seabornScatterMatrix','figure')
[Input('upload', 'contents')],
[State('upload', 'filename')])
def update_figure(content,filenameList):
#dcc.Storage(id='session', storage_type='session'),
#if content or filenameList is None:
# raise PreventUpdate
fullDf = pd.DataFrame()
if not content:
return [{'test':1}]
for table, fileName in zip(content, filenameList):
try:
if '.csv' in fileName:
content_type, content_string = table.split(',')
decoded = base64.b64decode(content_string)
df = pd.read_csv(io.StringIO(decoded.decode('utf-8')), sep='\t')
elif 'xls' in fileName:
df = pd.read_excel(io.BytesIO(decoded))
except Exception as e:
print(e)
return html.Div(['There was an error processing this file.'])
fullDf = pd.concat([fullDf, df])
fullDfDict = fullDf.to_dict('rows')#'index'
#print(fullDfDict)
#fullDf=functions.factorize(fullDf)
#figure = sns.pairplot(data=fullDf[['ContactIssue', 'GripperMark', 'DarkDefaultArea', 'SysInfoSystemNo']],
# hue='SysInfoSystemNo')
#print(figure)
return fullDfDict
The thing is, with dash_table experiments and the output “rows” it works! Why is that?