Hi,
I can’t be sure if I’m using the below correclty or if there is an issue with the multiselct or if it’s to do with my working environment.
multiple_files = param.MultiFileSelector(path='../../*/*.py?', precedence=0.5)
The problem I’m having with the multiselect param is that is does not appear to be accepting path, no issues with the single file select, it functions I think normally and left in code for comparison.
Wherever my .ipynd file is stored is what the multiselect root directory links too visually in the GUI. I tried replacing the path string with multiple permutations and reverse slashes, going deeper in the path rather than somewhere else. Further I pretty much dropped in the file select widget fileselector, that seems to work fine I just don’t know how to trigger a watch event from the widget rathar than param so have been persisting with the param multiselect.
minimal example:
import param
import panel as pn
import pandas as pd
pn.extension()
class FileInput(param.Parameterized):
files = param.MultiFileSelector(path='C:/jupyter/data/*.csv?')
@pn.depends("files", watch=True)
def _files(self):
print("multi file selection:")
def view(self):
return pn.Column(
self.param['files'],
)
app = FileInput()
app_view = app.view()
component = pn.Column(
app_view,
)
template = pn.template.FastListTemplate(
sidebar_width = 750,
sidebar=[component]).servable();
The code I’ve been using with just any random .csv should be fine:
import param
import panel as pn
import pandas as pd
pn.extension()
class FileInput(param.Parameterized):
data = param.DataFrame()
file = param.FileSelector(path='C:/jupyter/data/*.csv')
files = param.MultiFileSelector(path='C:/jupyter/data/*.csv?')
def __init__(self, **params):
super().__init__(**params)
@pn.depends("files", watch=True)
def _files(self):
filepath = self.files[0] # <- only want one file in this case
filepath = filepath.replace("\\", "/") # <- get the path into shape for pandas
self.data = pd.read_csv(filepath)
print("multi file selection:")
print(self.data.head())
@pn.depends('file', watch=True)
def _file(self):
filepath = self.file
filepath = filepath.replace("\\", "/")
self.data = pd.read_csv(filepath)
print("single file selection:")
print(self.data.head())
def view(self):
return pn.Column(
self.param['files'],
self.param['file'],
)
app = FileInput()
app_view = app.view()
#app_view
component = pn.Column(
app_view,
)
template = pn.template.FastListTemplate(
site="Company",
title="File Viewer",
main=[],
sidebar_width = 750,
sidebar=[component]).servable();
Any advice, suggestions would be appreciated.