2

I would like to import some nodes from csv file using feed_import module in Drupal 7. The original CSV file has around 500k entries and I have to do some filtering before importing. (the result will be under 40k).

Now, I have seen on drupal.org that feed_import has the possibility of adding some filters, but I cannot find the way to apply them.

Anyways I haven't seen nothing about the lenght of the field or about the type of content (numeric, alphanumeric, letters only), and I have to filter on these criteria.

Can that be made? Or should I try to do the filtering in PHP before using feed_importer?

3

You can create a new module and implement the hook_feeds_presave() function like the following example:

function hook_feeds_presave(FeedsSource $source, $entity, $item) {
  // create your filter conditions here
  if ($entity->feeds_item->entity_type == 'node') {
    // Skip saving this entity.
    $entity->feeds_item->skip = TRUE;
  }
}
1

I am using feed importer for long & I like this module very much. Filtering data while importing can be done but there is no direct option in the feed importer setting which you are looking for.

First filter is, field setting. As feed importer import data for fields, so the imported data always depend upon field setting first.

Then there is another module which can make your life easier while importing data, named Feed Tamper. You can add several plugin for any mapping like - trim, truncate, keyword filter, implode/explode, convert case, find replace, REGEX etc.

All plugins are handy and easy to use & it work like charm with feed importer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.