Skip to content

Example code for parsing a local CSV file and importing the data into Drupal via JsonApi

Notifications You must be signed in to change notification settings

mrkmiller/CSV-to-Drupal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example CSV import into Drupal

This is just some example code for taking a local CSV file and importing each row as a node into Drupal.

Setup

  1. 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.

  1. Installation of Node.js packages.
npm install
  1. 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.

Running the Import

  1. Test the CSV parsing.
npm test
  1. Import the files into Drupal.
npm start

About

Example code for parsing a local CSV file and importing the data into Drupal via JsonApi

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published