Importing Content into Drupal

Share this article

One of the most painful steps in any web system is importing content — especially so with Drupal. It is something that I have always dreaded. Images of CSV custom scripts and line by line parsing of data or awkward SQL commands come to mind. Yuck!

That is all in the past. I am happy now. I recently discovered a module that is a crown jewel in the Drupal Contrib community — Feeds.

Feeds Module

Feeds module is useful for many things (RSS/ATOM/OPML aggregation and importing, PubSubHubbub support, CSV importing and more) but for now I will just be focusing on the CSV import functions. It is quite straightforward to set up.

The very fist step is to actually install the module into your Drupal site. In the upcoming Drupal 7 release this will be as easy as clicking — Drupal 7 supports web based installing of modules. For Drupal 6 we don’t have such luxuries, it is manual all the way. So first, download the module. A quick note, the module does not yet have an official release (it is at 6.x-1.0-alpha14) but in saying that, it works very well. Once downloaded, unpack it and move or upload it to your /sites/all/modules directory. Visit your Admin module area (/admin/build/modules/) to install it.

Now it is installed and that was the easy part! There is a bit of clicking ahead, but trust me. It is worth the effort.

First, quickly create a new Feed Importer (/admin/build/feeds/create) and give it a name (this will become the URL to access the importer). Now there are a number of steps which are highlighted with the following image:

Steps to CSV importing

  1. Basic Settings: Make the following changes – Attach to content type change to ‘stand alone form’, minimum refresh set to ‘never’.
  2. Fetcher: Set this either to direct file upload or HTTP retrieval.
  3. Parser: Choose CSV parser.
  4. Processor: Choose Node processor.
  5. Node Processor Settings: Choose the content type you are importing into. You can optionally set existing nodes to be updated and also if you want the imported content to expire
  6. Create Nodes Settings: Here is where you map the CSV column header to the field name of the Node.

That is it for setting up the importing process. A number of steps, but they really are quite simple. Now you need to actually import the content. Visit the importing page (/import) and click on the name of the importer you created above. Upload the CSV file and Feeds module will immediately start work at creating your nodes. If you made a mistake in any of your mappings you can easily delete the last imported content and start again. This has saved me a number of times whilst I am in the testing phase.

This is only tapping a small piece of what this module can do. So I encourage you to try it out.

David PetersonDavid Peterson
View Author
Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form