You are here

private function WeatherCommands::read in Weather 2.0.x

Same name and namespace in other branches
  1. 8 src/Commands/WeatherCommands.php \Drupal\weather\Commands\WeatherCommands::read()

Read.

File

src/Commands/WeatherCommands.php, line 79

Class

WeatherCommands
Drush command to add support to weather module (import weather csv file).

Namespace

Drupal\weather\Commands

Code

private function read() : self {
  $file = $this
    ->csv();
  $i = 0;
  $items = [];
  while (($line = fgetcsv($file, 0, '	')) !== FALSE) {
    $items[] = $line;
    if (++$i % 500 === 0) {
      $this
        ->logger()
        ->info("read {$i}");
    }
  }
  fclose($file);
  $this->items = $items;
  return $this;
}