I have a csv parser and I want to pull it automatically via http fetcher. Currently I don't do this because the first row contains headers and the header values are not unique, so I always have to edit them for my mapping. In my case, the source data has two addresses, one for home and one for an office. The city, state, and zip fields are all labeled the same in the header: 'city', 'state', and 'zip'.

Is there a way in the mappings to specify the first or second occurrence of a particular field, or perhaps to just specify the mapping by position (ie, the 8th field)?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

MegaChriz’s picture

Yes, this is possible.

  1. Check the option "No headers" on the settings page for the CSV parser.
  2. On the mapping configuration page, name your mapping sources 0, 1, 2, etc.

To prevent the first row (the header) from being imported:

  1. Install the module Feeds Tamper.
  2. Go to your feeds importer configuration and click on the "Tamper" tab (admin/structure/feeds/[importer_id]/tamper).
  3. Add a keyword filter for one of the columns. Choose a column of which you are sure that none of the rows contains the exact same value as the column title. For example, if your column title is "city", none of the rows in the city column must have the value "city".
  4. Type the name of the column in the "Words or phrases to filter on" field and check the options "Exact" and "Invert filter".

See also the attached images.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.