Let's say I have a CSV file like this:

apple, fruit, green 
banana, fruit, yellow 
kiwi, fruit, brown 
carrot, vegetable, orange 
potato, vegetable, brown 

You get the idea. Is it possible to import this CSV file such that specified fields (in this case TYPE and COLOR) are taxonomies, and new taxonomy terms are created automatically?

I really want to do this in Drupal 8, but perhaps a method would be to do it in Drupal 7 and then migrate the data.

  • In D8, In manage form display, have you tried using autocomplete widget (tag style) and in manage fields, edit field, making sure the auto create checkmark is on? see pic
    – No Sssweat
    Sep 6, 2016 at 8:27
  • I don't think that is relevant - I am talking about importing data, not the user form.
    – James
    Sep 6, 2016 at 10:27

2 Answers 2


It's not clear whether you're looking for a front-end tool, or help with implementing this using the migration APIs. If the latter, in Drupal 8 you can use the migrate_source_csv source plugin with the entity_generate process plugin provided in migrate_plus. Your migration YAML file might look something like

id: food
label: 'Import food nodes'
  plugin: csv
  path: directory/my_csv_file.csv
  header_row_count: 1
    - NAME
    plugin: default_value
    default_value: food
  title: NAME
    plugin: entity_generate
    source: TYPE
    plugin: entity_generate
    source: COLOR
  plugin: 'entity:node'

The entity_generate plugin will lookup the incoming value in the appropriate vocabulary, create it if it doesn't already exist, and return a reference to the (possibly new) term.


Sure, this is possible, but there are many, many ways of going about it depending on your use case.

The simplest way would be to add a route item and menu link in the admin area (wherever you feel appropriate) which has a form, containing an upload field.

The validation of that form ensures the file is a CSV, then the submission function processes that file, iterates the row, and checks that the term exists and if not, creates it.

This can be done in 7 or 8.


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.