0

I have a content type "Car". The fields are "Title", "Body" and "Gearbox". The "field type" of the field "Gearbox" is "List (integer)", and the "Allowed values list" for this field (in the "key|label" format) are:

1|manual
2|automatic
3|semiautomatic

I want to import content from a CSV file using a standard node import with Feeds. My CSV is as follows

GUID,Title,Body,Gearbox
1,Lexus NX,blabla,automatic
2,Porsche Cayenne,bloblo,manual

On importing this CSV file, the value for "Gearbox" is not copied over. Instead, it appears as empty in the content. If I replace the values for "Gearbox" by their keys, as in this modified CSV file

GUID,Title,Body,Gearbox
1,Lexus NX,blabla,2
2,Porsche Cayenne,bloblo,1

then it works correctly.

Nevertheless, I'm not the end user and I need to leave the CSV file in its more human-friendly form that uses the "labels" instead of the "keys" (as in the original CSV above).

How can I do this? I.e. how can I have the import recognize the labels "manual", "automatic", etc instead of their corresponding keys?

2 Answers 2

1

It seems that this is a known issue. There is a patch at https://www.drupal.org/node/2006810

1
  • 2
    Thanks for coming back to provide a link to your own find solution since this will help others humbling over it here too.
    – nilsun
    Nov 14, 2014 at 0:52
0

Not sure what you mean with labels vs. keys. I assume you mean the database "names" of Drupal fields, the "machine_name"?

Otherwise, are you trying to import recursively? Or do you want to place all csv data into one content entry's list field to provide selection from it? It seems like there is a misunderstanding of the use of the list field. The value of the list field can (should) contain multiple selectable key|value pairs in "one" field data set. That's what the list field is meant for. But if you want to import each set recursively into another content dataset, you have to rearrange your csv file, since one line CSV means, one dataset, means one imported "node" of data.

But despite of this, Feeds importer provides the option to "map" fields in the import settings, so the import should work perfectly by mapping the fields (you should know by their label) to the corresponding field you have set up before and which are provided to map to in the settings fields select dialog.

It works similar to CSV import in excel or calc.

That's all I can say regarding the infos you gave. If you sue a specific Drupal version and a specific Feeds version missing any of the given advice, you should update your question.

Hope it helps at least a little bit.

Best regards from Berlin

1
  • 1
    I have rewritten the question as a simplified example. This should explain what I mean with keys and labels in the context of a list field. I do use the mapping, and it works correctly, but, as I mention now in the example, only if I rewrite my CSV to cointain keys. Thanks for your answer, it helped me to rewrite the question.
    – Steven
    Jun 23, 2014 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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