Using the Migrate Source CSV plugin
The Migrate Source CSV module provides a source plugin for utilizing .csv files as migration sources.
- A more complete example module can be found at
- General information on configuring/developing migrations can be found here:
How to import a simple CSV-file with Migrate Source CSV plugin
This very basic example will show you how to import Title and Body into the Article content type from a CSV-file.
- Download Migrate Source CSV and enable it.
- Download Migrate Plus and enable it
- Download Migrate Tools and enable it.
- Ensure you're using the latest version of Drush.
- Create a sample CSV-file called
acme_articles.csvwith the following content:
Id2,title,body 1,title 1,some body text 1 2,title 2,some body text 2 3,title 3,some body text 3
- Navigate to Administration > Configuration > Development > Synchronize (
admin/config/development/configuration/single/import), select Migration under Configuration type and enter this CSV-import configuration into the Paste your configuration here window (note the absolute path to the .csv file) , and hit import:
id: basics label: Import articles migration_groups: - ACME import source: plugin: csv path: '/path/to/file/acme_articles.csv' header_row_count: 1 keys: - Id2 process: title: title body: body type: plugin: default_value default_value: article destination: plugin: entity:node
- Go to your terminal and execute the command
drush migrate-import basicsto import the three example articles. If there is an error in your yml-configuration, and you try to resubmit it, you might have to change the
basicsto something else for it to get accepted (this is because by default, Drupal 8 doesn't allow existing configurations to be overwritten; you can however export the migration configuration (contains a
uuid) and reimport the changed configuration (with the exported
uuid) with the same
How to override the path to the CSV-file
using drupal console and a migration named
drupal config:override migrate_plus.migration.basics source.path /path-to.csv
View or edit existing migration configuration
drupal config:edit migrate_plus.migration.basics
You will need to run
drush cr to rebuild the cache before importing the file again. You'll need to rollback first too for any changes to "process" section (e.g. changes to default values) to be applied.