I’m trying to capture edited data in a tabulator.
Essentially what I want to do is have a user edit some data that is displayed in a table. Then capture this edited data by writing it to a database. Is this something that is possible in general?
I can see that it is possible to download filtered data. However, if the user edits this data these edits are not downloaded.
https://panel.holoviz.org/gallery/simple/save_filtered_df.html
Any ideas if this is possible in general.
Here is an example of what doesn’t work that I keep coming up against:
If you edit the data in the table and download, the downloaded data is the original data, the edits are lost. I would like to capture these edits.
e.g. run the example, on the first line change hp to 135 and download. The download has the original value of 130.
Thanks in advance
Aptperson
years = pn.widgets.MultiChoice(
name='Years', options=list(autompg.yr.unique()), margin=(0, 20, 0, 0)
)
mpg = pn.widgets.RangeSlider(
name='Mile per Gallon', start=autompg.mpg.min(), end=autompg.mpg.max()
)
@pn.depends(years, mpg)
def filtered_mpg(yrs, mpg):
df = autompg
if years.value:
df = autompg[autompg.yr.isin(yrs)]
df = df[(df.mpg >= mpg[0]) & (df.mpg <= mpg[1])]
return pn.widgets.Tabulator(df)
@pn.depends(years, mpg)
def filtered_file(yr, mpg):
df = filtered_mpg(yr, mpg)._value_param_value
sio = StringIO()
df.to_csv(sio)
sio.seek(0)
return sio
fd = pn.widgets.FileDownload(
callback=filtered_file, filename='filtered_autompg.csv'
)
pn.Column(pn.Row(years, mpg), fd, pn.panel(filtered_mpg, width=600), width=600).servable()