🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

How to manage multiple excel files in dcc.upload

Hi everyone,
i have 2 excel with months as there filenames, i just need to upload both of them using dcc.upload, and process that concatenated df of 2 excel files into a graphical output using dcc.graph, i am not getting the graph output this is my code

import base64
import datetime
import io

import dash
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
import dash_table
import plotly.graph_objs as go

import pandas as pd

external_stylesheets = [‘https://codepen.io/chriddyp/pen/bWLwgP.css’]

app = dash.Dash(name, external_stylesheets=external_stylesheets)

app.layout = html.Div([
dcc.Upload(
id=‘upload-data’,
children=html.Div([
'Drag and Drop or ',
html.A(‘Select Files’)
]),
style={
‘width’: ‘100%’,
‘height’: ‘60px’,
‘lineHeight’: ‘60px’,
‘borderWidth’: ‘1px’,
‘borderStyle’: ‘dashed’,
‘borderRadius’: ‘5px’,
‘textAlign’: ‘center’,
‘margin’: ‘10px’
},
# Allow multiple files to be uploaded
multiple=True
),
html.Div(dcc.Graph(id=‘my_graph2’)),
])

def parse_contents(contents,filename):
content_type, content_string = contents.split(’,’)

decoded = base64.b64decode(content_string)
try:
    if 'csv' in filename:
        # Assume that the user uploaded a CSV file
        df = pd.read_csv(
            io.StringIO(decoded.decode('utf-8')))
    elif 'xls' in filename:
        # Assume that the user uploaded an excel file
        df = pd.read_excel(io.BytesIO(decoded))
except Exception as e:
    print(e)

return df

@app.callback(Output(‘my_graph2’, ‘figure’),
[Input(‘upload-data’, ‘contents’),
Input(‘upload-data’,‘filename’)])
def update_output(contents,filename):
if contents is not None:
x=
y=
df=[parse_contents(c,v) for c,v in zip(contents,filename)]
dfA=pd.concat(df)
parent=‘xyz’
months=[‘Sep’,‘Oct’]
traceg=
for i in months:
dfg=dfA[dfA[‘MonthName’]==i]
dfgg=dfg[dfg[‘New’]==1]

        tog=dfgg[dfgg['Group']==parent]
        total_countg=tog.shape[0]

        flg=dfg[dfg['A_Group']==parent]
        flg=flg[flg['Solved']==1]
        flc_countg=flg.shape[0]

        esg=dfg[dfg['Group']==parent]
        esg=esg[esg['A_Group']!=parent]
        esc_countg=esg.shape[0]

        traceg.append(go.Bar(
        x=['Total_Count','Flc_Count','Esc_Count'],
        y=[total_countg,flc_countg,esc_countg],
        name=i))
    fig= go.Figure(data=traceg,layout=go.Layout(title="Month Over Metrics",xaxis=dict(title="Metric Title"),yaxis=dict(title="Count"),barmode='group'))
        
    
    return fig

if name == ‘main’:
app.run_server(debug=True)

Hi @vignesh , Did you already find a solution to this? I’m stuck at the same point.