content icon indicating copy to clipboard operation
content copied to clipboard

trouble loading csv

Open endquote opened this issue 4 months ago • 6 comments

Environment

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


endquote avatar Aug 20 '25 03:08 endquote

I think also the separator can only be ",". If you try any other it won't work

sot1986 avatar Aug 23 '25 20:08 sot1986

same problem

Jasonzyt avatar Aug 23 '25 21:08 Jasonzyt

i'm looking into this bug. I will submit a PR later.

Jasonzyt avatar Aug 24 '25 11:08 Jasonzyt

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

tazim404 avatar Sep 11 '25 19:09 tazim404

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.

github-actions[bot] avatar Nov 10 '25 19:11 github-actions[bot]

still wip in pr #3513

Jasonzyt avatar Nov 10 '25 21:11 Jasonzyt