How to import a CSV file into Contentful as entries using the Contentful Content Management API and JavaScript
This currently assumes your content type is already set up and ready to import entries.
npm i
Add a credentials.js file at the root of the project with the following:
module.exports.CMA_TOKEN = "your_cma_token;
module.exports.SPACE_ID = "your_space_id";
node index.js
The script will perform the following actions:
- Read the contents of ./resources/animals.csv
- Convert the contents of the csv file to an array of JavaScript objects
- Connect to a Contentful space and get a list of environments
- Check for an experimental environment and delete and recreate one as necessary
- For each item in the array, create a new 'animal' entry
- Publish the entries