I have a Migrate module class that works with CSV files and when I go through with the import it only goes through the first line of the CSV and then completes with a success message. That one line is imported correctly and the data is in place, but I'm wondering why it continues to stop at the first line.

When I run the import again it does not import anything and completes with success message again, mostly likely because the first line is already imported.

Any ideas?

class UserMigration extends MyMigration {
  public function __construct($arguments) {

    $this->description = t('Import Users');
    $columns = array(
      0 => array('username', 'Username'),
      2 => array('email', 'Email'),

    $this->source = new MigrateSourceCSV(drupal_get_path('module', 'my_module') . '/Users.csv', $columns);
    $this->destination = new MigrateDestinationUser();
    $this->addFieldMapping('name', 'username');
    $this->addFieldMapping('mail', 'email');
    $source_key = array(
      'username' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
    $this->map = new MigrateSQLMap($this->machineName, $source_key, MigrateDestinationUser::getKeySchema());

  • 2
    Is it possible that the CSV is saved with line endings in the wrong format? Be default, I think Migrate expects Unix format.
    – Dave Bruns
    Nov 13, 2013 at 18:58
  • @DaveBruns I believe that would be culprit. I've been having issues with these CSVs as they are saved from Server '03 and I'm on a Mac. I will re-generate the files on this machine and try again.
    – CR47
    Nov 13, 2013 at 19:06
  • 1
    @DaveBruns Re-generating the file with Uniux file endings worked perfectly. You may want to make this an answer to the question so I can accept it.
    – CR47
    Nov 13, 2013 at 19:47

1 Answer 1


It's possible that the CSV is saved with the wrong line endings. Try saving the CSV file with Unix-style line endings. By default, I believe Migrate expects a Unix format text file.

Your Answer

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

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