Import thousands of Excel lines into Drupal with Feeds

Saturday, October 7th 2017 - Drupal 7

Importing content into Drupal with Excel sheets is great for mapping columns to fields, especially for a non-technical client. But what if you have to import thousands of lines ?

On Drupal 7 at least, you will probably be stuck either by a number of lines limit, or by an excessive slowness of the import. Today I had to fix an import tool to be able to deal with more than 8000 lines of content, for a major company's Drupal websites factory. The tool was extremely slow and stopping at 200 lines.

Enter Spreadsheet Parser. This high-performance (for PHP) Excel parser library is designed to deal with big Excel files. And there's even a Drupal module to use the library with one of the main import tools, Feeds : Feeds Spreadsheet.

But... the module requires the use of the module Composer Manager. It's not something I could quickly decide to install on a multi-site Drupal factory, not at all. So here's a procedure to do it manually. Basically I'm patching the Feeds Spreadsheet module to delete the Composer Manager module dependency, and I'm including the library. I can't release a package of course, it's not the spirit. One should use Composer to manage the whole codebase from the beginning, and not in any other way. But you know how things are in our developers dreams and in reality...

So it's very simple :

On a development machine:

  • Get the archive of the module and extract it to sites/all/modules/patched/feeds_spreadsheet
  • In the .info of the module, remove the dependency to composer_update (delete or comment the line withdependencies[] = composer_manager)
  • Open a terminal in the module folder and run "composer install" to get the librairies
  • In the .module of the module, include the autoload : require_once 'vendor/autoload.php';

Then just upload your module on staging / production in sites/all/modules/patched and voilĂ  !

Add new comment