This is just some example code for taking a local CSV file and importing each row as a node into Drupal.
- Ensure Drupal is ready to import data.
On the drupal site be sure to have the JSON:API
and HTTP Basic Authentication
modules enabled.
Then on the JsonAPI config page /admin/config/services/jsonapi
, "Accept all JSON:API create, read, update, and delete operations." needs to be selected.
- Installation of Node.js packages.
npm install
- Edit the
index.js
file to reflect your custom info.
Change variable values for the CSV file location, Url, Username/Password, and Drupal Entity Type.
Add any Fields needed by the Drupal entity into the prepareNodes()
function.
- Test the CSV parsing.
npm test
- Import the files into Drupal.
npm start