Importing / Parsing a CSV into a collection

default discord avatar
Above The Clouds
last week
7

Hi there, anyone already done a CVS import to pre-populate a collection? Thanks in advance #community-help

  • default discord avatar
    thisisnotchris
    last week

    Hello @Above The Clouds - I've heard of people doing this, there may even be a code example in the discord archive



    However, you could create a script to loop over each entry in your CSV and hit the create endpoint for that collection



    You could also do it via a migration script in mongodb, but the API route feels easier to me

  • default discord avatar
    Above The Clouds
    last week

    Thanks @thisisnotchris - do you think it would be a good use case for a plugin?

  • default discord avatar
    thisisnotchris
    last week

    @Ab



    @Above The Clouds It could be if enough people are importing a lot of data!

  • discord user avatar
    denolfe
    Payload Team
    last week

    @Above The Clouds Here's an example script doing an import from csv

    https://payloadcms.com/community-help/github/user-csv-import-for-a-collection
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.