Import a CSV file into a Pandas DataFrame with PyScript (#3) 🐍
import asyncio
import panel as pn
import pandas as pd
from panel.io.pyodide import show
def process_file(event):
if fileInput.value is not None:
df = pd.read_csv(io.BytesIO(fileInput.value))
table.value = df
document.getElementById('table').style.display = 'block'
fileInput = pn.widgets.FileInput(accept='.csv')
uploadButton = pn.widgets.Button(name='Upload', button_type = 'primary')
table = pn.widgets.Tabulator(pagination='remote', page_size=10)
# hide pagination 'First, Prev [1][2][3] Next, Last'
document.getElementById('table').style.display = 'none'
uploadButton.on_click(process_file)
await show(fileInput, 'fileinput')
await show(uploadButton, 'upload')
await show(table, 'table')