Dash datatable import multiple files

Hello all,

First of all, I’ve been looking at many posts and links on the web and didn’t found any answer to my problem. So, basically I am building a webapp, which is reading datafiles (txt; csv or dat) using dcc.Upload. As far as I know, I found a topic where someone explained that dcc.Upload was bugged and wasn’t really able to import multiple files. BUT : I managed to do it and get the list of filenames clickes in the upload window. This done, I called as a callback a function that will process the file and return a dataFrame with 9 columns. 2 of them contain arrays of data. :

def update_output(list_of_contents, list_of_names, list_of_dates):
    print(list_of_names)
    dicData=[]
    j=0
    if list_of_contents is not None:
        
        c, n, d = list(zip(list_of_contents, list_of_names, list_of_dates))[0]
        for i in list_of_names:
            dataTemp=parseFiles.openDataFile(c, i, d).iloc[:, :]
            dataTemp.columns=columns_data
            dataTemp=dataTemp.to_dict("records")
            dicData.append([dataTemp])


            j+=1 

        try:
            #print(dicData)
            return dicData
        except:
            pass

So my problem is that everything goes well until I return the dicData list of dicts to the dataTable. For example, if I select 3 files, 3 rows are appearing, but nothing in the cells. I guess it’s a problem of data formatting that are taken in the cells, but I have many difficulties to figure it out. Maybe you could help me?

Thank you in advance :wink:

You must pass columns list too formatted like columns=[{“name”: i, “id”: i} for in columns_list]

Hello Jorge, thanks for your answer. Actually that’s what I did out of the function. I tried with it inside the function, but still the same :

columns_data = ["File name", "Record", "Sample", "T (°C)", "Viscos.", "Angle (°)", "RI", "Time", "Gamma"]

I found it out by myself. Actually I have to return a dataFrame directly from my parsing function and then I am able to loop on it and transform it into a dict.

Was wondering if you could post your final code. Struggling with this now