trouble loading csv
Environment
- Operating System: Darwin
- Node Version: v24.6.0
- Nuxt Version: 4.0.3
- CLI Version: 3.27.0
- Nitro Version: 2.12.4
- Package Manager: [email protected]
- Builder: -
- User Config: compatibilityDate, devtools, modules, css, content
- Runtime Modules: @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @vueuse/[email protected]
- Build Modules: -
Version
3.6.3
Reproduction
A reproduction is in the discussion here: https://github.com/nuxt/content/discussions/3489
In my use case:
export default defineContentConfig({
collections: {
people: defineCollection({
type: "data",
source: "org/gdc.csv",
schema: z.object({
"Work Email": z.string().email(),
}),
}),
},
});
const { data: tmpContent } = await useAsyncData("tmp-content", () => queryCollection("people").all());
[
{
"id": "people/org/gdc.csv",
"Work Email": null,
"extension": "csv",
"meta": {
"path": "/org/gdc",
"body": [
...my csv data is here...
],
"title": "Gdc"
},
"stem": "org/gdc",
"__hash__": "t_hC0vKvEj6NWa3r_goNjnn4BEvwNnHt6Y8WvNiIUHI"
}
]
Description
CSV data is not returned from queryCollection as it is for markdown. The result is an array of length 1 with a body attribute that has all the data.
The documentation mentions putting this in the config:
export default defineNuxtConfig({
content: {
build: {
csv: {
json: true,
},
},
},
});
But it seems to have no effect.
The documentation also seems to have errors. The example schema has "name, email, avatar", then has two example csv files, with "id, name, email", and "name, role, avatar".
Additional context
cc @peter-chipello
Logs
I think also the separator can only be ",". If you try any other it won't work
same problem
i'm looking into this bug. I will submit a PR later.
Having same issue. Wasted hours trying to debug this.
I didnt got the solution yet but if we look at .nuxt folder it creates content\contents.sqlite where it create all the table based on collection you have defined and store all the csv data into meta column.
Earlier i think it was my code but no it was the nuxt-content package itself
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.
still wip in pr #3513