When trying to import data that lives in a field that is a list there is no mapping option in the csv mapping options.

Comments

alex_b’s picture

Title: Importing any field that is an item in a list is not supported. » Mapping to String lists not supported

Looking at the code I can only imagine that string list types are not supported. Is there such a thing as string list types?

$numeric_types = array(
    'list',
    'list_boolean',
    'list_number',
    'number_integer',
    'number_decimal',
    'number_float',
  );
  $string_types = array(
    'text',
    'text_long',
    'text_with_summary',
  );
jcarlson34’s picture

Looking at the code I can only imagine that string list types are not supported. Is there such a thing as string list types?

When creating a field in Drupal 7, three List types are available in the drop down:

List (float)
List (integer)
List (text)

In the database field_config table, the type is stored as "list_text" and the module is "list". So I guess string list types are new in Drupal 7?

It'd be great to have List (text) supported in the 7.x Feeds module if possible. Thanks for a great module alex_b!

David Goode’s picture

Status: Active » Reviewed & tested by the community
StatusFileSize
new692 bytes

Here's a patch which adds 'list_text' to the string mapper options. Also removes the 'list' numeric field type, which AFAIK doesn't exist? Confirmation? One outstanding issue is that for all the list fields, it doesn't verify if you are inserting an option that is one of the allowed values; makes editing the node destroy the data if this isn't true. Any thoughts on what to do about this Alex or others? May make a separate ticket.

johnv’s picture

This patch does not work if the imported value is numeric: value "xyz" works fine, value "123" does not, with the following list of allowed values:
1|xyz
2|123

jcarlson34’s picture

Status: Reviewed & tested by the community » Needs review

Looks like the patch still needs a tiny modification because 'list_integer' and 'list_float' need to be added while 'list_number' needs to be deleted.

From line 22 of drupal-root/modules/field/modules/list/list.module here are the types of lists available in Drupal 7:

/**
 * Implements hook_field_info().
 */
function list_field_info() {
  return array(
    'list_integer' => array(
      'label' => t('List (integer)'),
      'description' => t("This field stores integer values from a list of allowed 'value => label' pairs, i.e. 'Lifetime in days': 1 => 1 day, 7 => 1 week, 31 => 1 month."),
      'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
      'default_widget' => 'options_select',
      'default_formatter' => 'list_default',
    ),
    'list_float' => array(
      'label' => t('List (float)'),
      'description' => t("This field stores float values from a list of allowed 'value => label' pairs, i.e. 'Fraction': 0 => 0, .25 => 1/4, .75 => 3/4, 1 => 1."),
      'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
      'default_widget' => 'options_select',
      'default_formatter' => 'list_default',
    ),
    'list_text' => array(
      'label' => t('List (text)'),
      'description' => t("This field stores text values from a list of allowed 'value => label' pairs, i.e. 'US States': IL => Illinois, IA => Iowa, IN => Indiana."),
      'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
      'default_widget' => 'options_select',
      'default_formatter' => 'list_default',
    ),
    'list_boolean' => array(
      'label' => t('Boolean'),
      'description' => t('This field stores simple on/off or yes/no options.'),
      'settings' => array('allowed_values' => array(), 'allowed_values_function' => ''),
      'default_widget' => 'options_buttons',
      'default_formatter' => 'list_default',
    ),
  );
}

So the code should look like:

/**
 * Implements hook_feeds_processor_targets_alter().
 *
 * @see FeedsNodeProcessor::getMappingTargets().
 */
function field_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
  $numeric_types = array(
    'list_integer',
    'list_float',
    'list_boolean',
    'number_integer',
    'number_decimal',
    'number_float',
  );
  $string_types = array(
    'list_text',
    'text',
    'text_long',
    'text_with_summary',
  );

Pretty simple to modify but I don't know how to do patch files correctly yet. :)

jcarlson34’s picture

Version: 7.x-2.0-alpha2 » 7.x-2.0-alpha3
StatusFileSize
new743 bytes

Ok figured out how to patch finally.

Here's the patch additions from #5 for 7.x-2.0-alpha3 (which must have just been released).

johnv’s picture

Status: Needs review » Needs work

The patch works fine. It is not complete though, see my comment #4.
I dno't know to set the status to 'Needs work' or to RTBC and open a new issue.

jcarlson34’s picture

'Needs work' sounds about right.

We get the right field types now but something more must be needed to process it right then.

firestonej’s picture

Subscribing. This feature would be awesome.

ropaolle’s picture

Subscribing

retolist’s picture

Subscribing

froboy’s picture

Subscribing

johnv’s picture

Status: Needs work » Reviewed & tested by the community

Update on #4 and #7. Numeric values are processed correctly. It turned out to be a user error (field was declared twice in my input file, I changed 1st field, but 2nd field was mapped.)

ccheu’s picture

subscribing

kking’s picture

Status: Reviewed & tested by the community » Fixed

Commit 72fbb30ab073dec6d5727ebd22b9bd8584e0f6cf
Date: Fri Mar 4 17:34:24 2011 -0500

Issue #967018 by jcarlson34, David Goode, alex_b: Mapping to String lists not supported

ccheu’s picture

Patch #6 worked for me. Thanks!

Status: Fixed » Closed (fixed)

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

rowbotony’s picture

Hello, I am also encountering this issue on my site. I'm new to Drupal, and not a hardcore coder, so I'm hoping to report this issue in a comprehensive way so that someone smarter than me can know what's causing it, and how to patch it.

In short - I have a catalog built with nodes and fields. I'm trying to use Feeds to import the catalog via CSV. I have found that fields with the Type: list_text and Module: list are not displaying in the field mapping, so I can't map those fields from the CSV to the node. See attached for clarification, and please let me know if I may be of further assistance.

Thank you,
//Tony

johnv’s picture

Status: Closed (fixed) » Active

Just a silly question: you did apply the patch in comment #6?

rowbotony’s picture

When I initially installed Feeds earlier today I just pulled the latest git version which already includes the patch in - commit 72fbb30ab073dec6d5727ebd22b9bd8584e0f6cf. So yes, this is still occurring with the latest previously mentioned patch. Thanks -Tony

jcarlson34’s picture

Did you clear your site's cache? List text fields show up for me.

As for node_reference, check out #988856: Feeds mapper for node_reference and user_reference fields

rowbotony’s picture

Yes, I cleared the cache #drush cc all, disable/enabled, downloaded again, enable/flush cache. I've done that several times, still the list fields do not appear in the mapper.

rowbotony’s picture

Status: Closed (fixed) » Active

I've investigated further and found, with just a clean D7 install with Feeds, ctools, job_scheduler, Feeds Import, Feeds UI, etc. these list_text fields DO show up in the mapping as expected. So this is something particular to my config, I'll dig a little deeper and see what other module I have installed that may be interfering with my other site that's not showing these list mappings. Thanks, I'll post back if I find the culprit.

jcarlson34’s picture

Ugh that's so frustrating when that happens. Good luck tgroff. I hope you find the culprit quickly.

rowbotony’s picture

Status: Active » Closed (fixed)

OK, I found the problem. I retraced my steps a bit through bash_history... still can't find where I went wrong, but I must have fat-fingered something at some point. Long story short - the issue was because I had the wrong version installed. Even with the git clone --branch 7.x-2.x http://git.drupal.org/project/feeds.git, I have no idea how I was still running 7.x-1.x-dev. No matter, I've resolved the issue now with the proper feeds-7.x-2-dev version :).

Apologies for the false report. I'm quickly learning how to debug issues in Drupal. This is the second time I've had an issue on my site, that has not existed on a fresh install trying to recreate the issue. So I think it's best practice for me to test on a fresh install before reporting a bug. Thanks for your understanding :)

Status: Active » Closed (fixed)