Populating drupal nodes from a csv file


If you have lots of data that you need to post on your drupal site, you import is and use it to populate drupal nodes. This way you would not have to copy paste all of them manually.

Installation

First download and install Chaos Toolsfeeds and job scheduler modules. If you use drush, simply type the following to install.

$ drush en ctools -y
$ drush en feeds -y
$ drush en job_scheduler -y

Make sure you have Feeds, Feeds Admin UI, and Feeds Import enable in the modules page.

Setting up Feeds

  1. Click on Structure > Feed Importers
  2. Click on Clone in the same row as Node import
  3. Type “Quotes” for Name and “words of wisdom” for Description. Click on create.
  4. Click on Settings link next to Basic Settings. Attach to content type = basic page, Period import = Off, Import on submission = checked, Process in background = unchecked. Click on Save.
  5. Click on Change link next to Fetcher. Select File upload. Click on Save.
  6. Click on Settings link next to File upload. Make sure csv is listed in Allowed file extensions.
  7. Click on Change link next to Parser. Choose CSV parser. Save.
  8. Click on Settings link next to Node processor. Bundle = basic page, Do not update existing nodes, skip hash check = unchecked, Text format = Filtered HTML, Authorize = checked, Expire nodes = Never. Save.
  9. Click on Mapping link next to Node processor and check Remove for guid and Published. Save.

Importing Data

  1. Click on Content > Add Content
  2. Title = “import quotes”, Body = “importing quotes”
  3. Under File, Choose File and navigate to your csv file. Click on Save.
  4. The import is complete.

Copy/Paste the following into notepad and save as a.csv to create your csv file.

title,body
"Quote 1","Be more concerned with your character than your reputation, because your character is what you really are, while your reputation is merely what others think you are.<br>- John Wooden"
"Quote 2","Speak when you are angry, and you will make the best speech you'll every regret.<br>- Lawrence J. Peter"
"Quote 3","Imagination is more important that knowledge. Knowledge is limited. Imagination encircles the world.<br>- Albert Einstein"

Now that the import is complete, click on Content > Find Content. You should see three nodes with Title Quote 3, Quote 2, and Quote 1.