Can't select parquet file using FileInput


I am trying to use pn.widgets.FileInput to allow the user to select a file from its local system.
In my case, is a parquet file, which has multiple partitions.
Seems that FileInput interprets the parquet file as a folder and doesn’t allow its selection as such, but rather it drills down into it.

What option(s) do I have to allow the user to select a Parquet file?

Thank you!

Hi @sorin

Its hard to figure out what goes wrong for you. It would help with a minimum, reproducible example.

The below works for me

import pandas as pd
import panel as pn
from io import BytesIO


data = pd.DataFrame({
    "x": [1,2]
data.to_parquet("test.parquet", index=False,)

file_input = pn.widgets.FileInput(name="Upload", accept=".parquet")

def uploaded(value):
    if value:
        string_io = BytesIO(value)
        return pd.read_parquet(string_io)
        return "Please upload a file"

pn.Column(file_input, uploaded).servable()


I forgot to mention one important aspect: the parquet file has multiple partitions because it was created using dask and that’s why it shows like a folder.

1 Like

I’m not sure can supports the upload of a folder currently.

If not then you could either

  • Ask your users to zip the parquet folder and then upload it
  • Implement a custom ParquetFolderInput using ReactiveHTML.

What is interesting though, is that if I use drag&drop, the filename appears correctly in the element - although I haven’t continue as is not a desired behavior. :slight_smile:

1 Like