Inputs.file & DuckDB

Hi,

I wanted in a notebook to show how duckdb works with observablehq. Standard approach based on observable documentation works fine:

db = DuckDBClient.of({
  match : FileAttachment("example.csv")
})

after attaching the file. However, I wanted allow users to attach a file from disk based on Inputs.file. My code is

viewof csvfile = Inputs.file({label: "CSV file", accept: ".csv", required: true})
db_input = DuckDBClient.of({
  match : FileAttachment(csvfile["name"])
})

this gives me the following error:

Is there a workaround ?

Reproducible example here

Maybe try this:

db_input = DuckDBClient.of({match: await csvfile.csv()})

1 Like

Thanks for the reply ! Worked like a charm !

1 Like