You are here

protected function MigrateListCSV::getNextLine in Migrate 7.2

Get the next line of the CSV file. Returns an array of the next line, keyed by headers if required

Return value

array

3 calls to MigrateListCSV::getNextLine()
MigrateListCSV::computeCount in plugins/sources/csv.inc
Return a count of all available IDs from the source listing.
MigrateListCSV::getIdList in plugins/sources/csv.inc
Return an array of IDs from the CSV file.
MigrateListCSV::__construct in plugins/sources/csv.inc
Constructor for MigrateListCSV.

File

plugins/sources/csv.inc, line 182
Define a MigrateSource for importing from comma separated values files.

Class

MigrateListCSV
Implementation of MigrateList, for retrieving a list of IDs to be migrated from a CSV file.

Code

protected function getNextLine() {

  // escape parameter was added in PHP 5.3.
  if (version_compare(phpversion(), '5.3', '<')) {
    $row = fgetcsv($this->csvHandle, $this->fgetcsv['length'], $this->fgetcsv['delimiter'], $this->fgetcsv['enclosure']);
  }
  else {
    $row = fgetcsv($this->csvHandle, $this->fgetcsv['length'], $this->fgetcsv['delimiter'], $this->fgetcsv['enclosure'], $this->fgetcsv['escape']);
  }

  // Key the array with the headers
  if (!empty($this->headers) && $row) {
    $row = array_combine($this->headers, $row);
  }
  return $row;
}