# Use read\_csv in duckdb call for a locale file

**URL:** <https://talk.observablehq.com/t/use-read-csv-in-duckdb-call-for-a-locale-file/9033>\
**Category:** Help\
**Created:** [March 30, 2024, 5:48am UTC](https://talk.observablehq.com/t/use-read-csv-in-duckdb-call-for-a-locale-file/9033 "2024-03-30T05:48:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saptarshiguha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/saptarshiguha/32/8656_2.png) [@saptarshiguha](https://talk.observablehq.com/u/saptarshiguha)\
**Post date:** [March 30, 2024, 5:48am UTC](https://talk.observablehq.com/t/use-read-csv-in-duckdb-call-for-a-locale-file/9033/1 "2024-03-30T05:48:37Z")

</div>

Hello,  
Is such a call allowed

```auto
await db.sql`CREATE TABLE longform AS SELECT * FROM read_csv('./data/poem_long_form.csv');`

```

I got the following `Error: IO Error: No files found that match the pattern "./data/poem_long_form.csv"`, though it feels surprising why this would be an error when the following works

```auto
await db.sql`CREATE TABLE addresses
  AS SELECT *
  FROM read_parquet('https://static.data.gouv.fr/resources/bureaux-de-vote-et-adresses-de-leurs-electeurs/20230626-135723/table-adresses-reu.parquet')
  LIMIT 100`;

```

(the reason im trying this is because this

```auto
const db = await DuckDBClient.of({ 
       longform: FileAttachment("./data/poem_long_form.csv"), 
       prompt: FileAttachment("./data/poem_prompts.csv")
})

```

for some reason is treating the first line of `./data/poem_prompts.csv` as a row and not as a header. not sure why since the spec says otherwise. The first csv loads fine)

thanks much  
saptarshi

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [March 30, 2024, 5:10pm UTC](https://talk.observablehq.com/t/use-read-csv-in-duckdb-call-for-a-locale-file/9033/2 "2024-03-30T17:10:42Z")

</div>

You can pass additional options to `DuckDBClient.of` if you need to change the default behavior. For example:

```js
const db = await DuckDBClient.of({ 
  longform: FileAttachment("./data/poem_long_form.csv"), 
  prompt: {
    file: FileAttachment("./data/poem_prompts.csv"),
    header: false
  }
});

```

You can find the supported options here:

> **[CSVInsertOptions | DuckDB-WASM](https://shell.duckdb.org/docs/interfaces/index.CSVInsertOptions.html)**
>
> Documentation for DuckDB-WASM

You can’t use `read_csv('./path/to/file')` in SQL because it is not statically analyzable by Framework, so Framework doesn’t know you need the file, can’t know to generate it with a data loader, include it in the built site, etc.

---

<div class="post-metadata">

**Author:** ![saptarshiguha](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/saptarshiguha/32/8656_2.png) [@saptarshiguha](https://talk.observablehq.com/u/saptarshiguha)\
**Post date:** [April 1, 2024, 3:36am UTC](https://talk.observablehq.com/t/use-read-csv-in-duckdb-call-for-a-locale-file/9033/3 "2024-04-01T03:36:46Z")

</div>

Thanks much
