# Inputs.file & DuckDB

**URL:** <https://talk.observablehq.com/t/inputs-file-duckdb/7974>\
**Category:** Help\
**Created:** [May 25, 2023, 7:21am UTC](https://talk.observablehq.com/t/inputs-file-duckdb/7974 "2023-05-25T07:21:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![linogaliana](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/linogaliana/32/7358_2.png) [@linogaliana](https://talk.observablehq.com/u/linogaliana)\
**Post date:** [May 25, 2023, 7:21am UTC](https://talk.observablehq.com/t/inputs-file-duckdb/7974/1 "2023-05-25T07:21:39Z")

</div>

Hi,

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

```auto
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](https://observablehq.com/@observablehq/input-file). My code is

```auto
viewof csvfile = Inputs.file({label: "CSV file", accept: ".csv", required: true})

```

```auto
db_input = DuckDBClient.of({
  match : FileAttachment(csvfile["name"])
})

```

this gives me the following error:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/6/6e16e89a5795a53c53bd553fcee7bb0253172801.png)

Is there a workaround ?

**Reproducible example [here](https://observablehq.com/@linogaliana/testing-input-files)**

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [May 25, 2023, 8:09am UTC](https://talk.observablehq.com/t/inputs-file-duckdb/7974/2 "2023-05-25T08:09:30Z")

</div>

Maybe try this:

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

---

<div class="post-metadata">

**Author:** ![linogaliana](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/linogaliana/32/7358_2.png) [@linogaliana](https://talk.observablehq.com/u/linogaliana)\
**Post date:** [May 25, 2023, 8:21am UTC](https://talk.observablehq.com/t/inputs-file-duckdb/7974/3 "2023-05-25T08:21:57Z")

</div>

Thanks for the reply ! Worked like a charm !

---

<div class="post-metadata">

**Author:** ![emauviere](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@emauviere](https://talk.observablehq.com/u/emauviere)\
**Post date:** [July 15, 2023, 3:52pm UTC](https://talk.observablehq.com/t/inputs-file-duckdb/7974/4 "2023-07-15T15:52:26Z")

</div>

It seems to me that this first convert the csv stream to a JS array, which is further loaded by DuckDB. So the specific DuckDB velocity when dealing with (parsing) CSV files is probably shunted?  
Likewise, a semicolon delimiter won’t be automatically recognized, although it is with FileAttachment().

I guess that the DuckDBClient needs to now the file’s type (.csv), which it can guess from the filename extension in “FileAttachement”, but not from the Input.file stream

---

<div class="post-metadata">

**Author:** ![emauviere](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@emauviere](https://talk.observablehq.com/u/emauviere)\
**Post date:** [July 16, 2023, 5:18pm UTC](https://talk.observablehq.com/t/inputs-file-duckdb/7974/5 "2023-07-16T17:18:58Z")

</div>

I’d eventually suggest (upon scanning DuckDbClient.js code):  
db\_input = DuckDBClient.of({  
match : {  
file : Object.assign(csvfile, {mimeType:‘text/csv’}),  
//delim: ‘;’ // to specify if \<\> ‘,’  
}  
})
