0

I have a freshly composer installed Drupal 8.6.13. I tried to migrate csv sources and allways got the error message

[error] Migration failed with source plugin exception: id is defined as a source ID but has no value.

I switched to an example that is running in another installation https://www.drupal.org/docs/8/api/migrate-api/migrate-source-plugins/migrating-data-from-a-csv-source, but still get this error.

My versions: migrate 8.6.13, migrate_plus 8.x-4.1, migrate_source_csv 8.x-2.2, migrate_tools 8.x-4.1

Does anyone have an idea what causes the error?

This are the files:

CSV:

id,title,body 
1,title 1,some body text 1 
2,title 2,some body text 2 
3,title 3,some body text 3

Migration configuration:

id: article_csv_import
label: Import articles
migration_groups:
  - ACME import
source:
  plugin: csv
  path: 'public://articles.csv'
  delimiter: ','
  enclosure: '"'
  header_row_count: 1
  keys:
    - id
  column_names:
    0:
      id: 'Unique Id'
    1:
      title: 'Title'
    2:
      body: 'Post body'
process:
  title: title
  body: body
  type:
    plugin: default_value
    default_value: article

destination:
  plugin: entity:node
0

I already had the same error you've got; in fact it's a mistake : Please double check that the delimiter set in the yml file is the same as in your source file (edit it with notepad++ to be sure). Sometimes Excel change delimiter when reopening csv file before resave it without settings file format.

Also, note the column_names key is not mandatory, as the plugin will automagically extract column from your file (see migrate_source_csv\src\Plugin\migrate\source\CSV.php line 110 ... 123). Here you can also print the $column_names array to check if it contains same number of items as your file columns.

BR

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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