I'm trying to migrate a CSV file of taxonomies (cities) into Drupal 8. The CSV has a code and the city name, for example:
City_Code,"Name"
1234,"CITY A"
5678,"CITY B"
I have the following as my current migration, which is working, and importing the city names. My problem is I also added a field with the machine name `field_legacy_id` to my term (Drupal 8), which I would like to populate with the OLD `City_Code` for reference later.
langcode: en
status: true
dependencies: { }
id: cities
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: null
label: 'My Import'
source:
plugin: csv
path: /path/to/data.csv
delimiter: ','
enclosure: '"'
header_row_count: 1
keys:
- City_Code
column_names:
0:
City_Cd: City_Code
1:
Name: Name
process:
vid:
plugin: default_value
default_value: city
name: Name
field_leagcy_id: City_Code
destination:
plugin: 'entity:taxonomy_term'
migration_dependencies: null
The field_legacy_id
seems to be ignored and I can't figure out how to get the migration to populate the field value. Thanks.
This is the field attached to the `taxonomy.vocabulary.city`:
langcode: en
status: true
dependencies:
config:
- field.storage.taxonomy_term.field_legacy_id
- taxonomy.vocabulary.city
id: taxonomy_term.city.field_legacy_id
field_name: field_legacy_id
entity_type: taxonomy_term
bundle: city
label: legacy_id
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
min: null
max: null
prefix: ''
suffix: ''
field_type: integer
(Edited for formatting)
Comments
column_names
I did a D8 csv migration, but never used column_names
(I used the original implicit column names from the csv),
so I was curious and looked it up in the documentation:
https://www.drupal.org/docs/8/modules/migrate-source-csv/using-the-migrate-source-csv-plugin
Maybe the migration could work with (?):
field_leagcy_id: City_Cd
(or use
since the keys section also seems to use the name).
I recently ran into this same
I recently ran into this same issue with a similar data set. For some reason, migrate does not interpret numeric columns when they are the first to appear within a CSV.
Reorder the CSV to place your numeric column after a column with text data.
Ron Williams
http://ronwilliams.io/
Great Tip! Anyone know how to
Great Tip! Anyone know how to also import the country and province as lineair terms? Greetings,
How are country and province
How are country and province related? Are these terms from the same vocabulary or from different ones?
With feeds you can easy import terms (or nodes).
So you need 2-3 import:
1. import terms
2. update terms and specify parent terms. State for each province.
If some states and provinces haму have same name - you need to import and update them by ID? not by name. Yes, you can specify ID during import.