New to panel = looking to load CSV file into dataframe / Pandas

Hi @jsegrich

I is not clear to me how exactly you want to pull CSV into a dataframe. But here is an example that uses the FileInput widget and Tabulator table.

This enables the user to input a csv file and view it in a table.

from io import StringIO

import pandas as pd
import panel as pn


def to_dataframe(value):
    if not value or not isinstance(value, bytes):
        return pd.DataFrame()

    string_io = StringIO(value.decode("utf8"))
    return pd.read_csv(string_io)


file_input = pn.widgets.FileInput(sizing_mode="fixed")
table = pn.widgets.Tabulator(pn.bind(to_dataframe, file_input))

layout = pn.Column(file_input, table)

if pn.state.served:
    pn.extension("tabulator", sizing_mode="stretch_width")

    pn.template.FastListTemplate(site="Panel", title="CSV FileInput", main=[layout]).servable()

trees.csv (849 Bytes)

Versions: Panel=1.1.1