Uploaded file type of object

Hi, I followed the instructions of How to select a file using FileInput, convert it into a DataFrame and access it?

import io
import panel as pn
import pandas as pd
import openpyxl
import param

pn.extension()

xlsx_file_input = pn.widgets.FileInput(accept=".xlsx")

def load_excel_file(file_bytes):
    if file_bytes is not None:
        return pd.read_excel(io.BytesIO(file_bytes))
    
get_dataframe = pn.bind(load_excel_file, xlsx_file_input)
dash = pn.Column(xlsx_file_input, get_dataframe)

dash

but when I try to apply a pandas methods like get_dataframe.columns it throws an error.
image

Is there a way to retrieve and make use of the dataframe bound in the function?

Hi @jase64

See How to get columns of uploaded excel file? - Panel - HoloViz Discourse.

Hi @Marc,

Now you gave me the hint, it seems obvious! Thanks a lot :slight_smile:

1 Like