You are here

protected function CSV::createReader in Migrate Source CSV 8.3

Construct a new CSV reader.

Return value

\League\Csv\Reader The reader.

1 call to CSV::createReader()
CSV::getReader in src/Plugin/migrate/source/CSV.php
Get the CSV reader.

File

src/Plugin/migrate/source/CSV.php, line 276

Class

CSV
Source for CSV files.

Namespace

Drupal\migrate_source_csv\Plugin\migrate\source

Code

protected function createReader() {
  if (!file_exists($this->configuration['path'])) {
    throw new \RuntimeException(sprintf('File "%s" was not found.', $this->configuration['path']));
  }
  $csv = fopen($this->configuration['path'], 'r');
  if (!$csv) {
    throw new \RuntimeException(sprintf('File "%s" could not be opened.', $this->configuration['path']));
  }
  return Reader::createFromStream($csv);
}