I’m following the tutorial on https://dash.plot.ly/dash-core-components/upload and can’t quite figure out how to upload a CSV file into columns IDs I have made already in the program. Even when df.to_dict(‘records’) seemingly prints out the right values with the right column titles, it still doesn’t show up in the datatable.
do the columns IDs defined in your app match exactly (case, whitespaces…) the names of columns in your CSV file? Could you please share your code and your CSV file (or one CSV file reproducing the issue)?
The column names were the problem, thanks! I was also wondering if it is possible to export different columns to different tables. This is what I currently have. I would like to implement a way to split up the df.to_dict(‘records’) to different data for different tables.
def parse_contents(contents, filename):
content_type, content_string = contents.split(’,’)
decoded = base64.b64decode(content_string)
if ‘csv’ in filename:
# Assume that the user uploaded a CSV file
elif ‘xls’ in filename:
# Assume that the user uploaded an excel file
[Input(‘battery-upload’, ‘contents’), Input(‘battery-charging-table’,‘columns’)],
[State(‘battery-upload’, ‘filename’), State(‘battery-charging-table’, ‘data’)])
def update_output(contents, cols, filename, rows):
if contents is None:
df = parse_contents(contents, filename)