public function read_data() { $this->column_labels = array(); $this->column_indices = array(); foreach (new FileIterator($this->text_path["obis"]["ranges_OBIS"]) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = ContentArchiveReader::line_to_array($line, ",", "\""); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $this->process_line_data($line_data); } }
public function build_archive() { $this->path_to_archive_directory = CONTENT_RESOURCE_LOCAL_PATH . "/{$this->resource_id}/"; $this->archive_builder = new \eol_schema\ContentArchiveBuilder(array('directory_path' => $this->path_to_archive_directory)); $this->column_labels = array(); $this->column_indices = array(); $this->taxon_occurrences = array(); foreach (new FileIterator(self::TAXA_URL) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = ContentArchiveReader::line_to_array($line, ",", "\""); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $taxon = $this->add_taxon($line_data); $this->taxon_occurrences[$taxon->taxonID] = $this->add_occurrence($line_data, $taxon); } $this->column_labels = array(); $this->column_indices = array(); foreach (new FileIterator(self::DUMP_URL) as $line_number => $line) { if ($line_number % 1000 == 0) { echo "{$line_number} :: " . time_elapsed() . " :: " . memory_get_usage() . "\n"; } $line_data = ContentArchiveReader::line_to_array($line, ",", "\""); if ($line_number == 0) { $this->column_labels = $line_data; foreach ($this->column_labels as $k => $v) { $this->column_indices[$v] = $k; } continue; } $this->process_line_data($line_data); } $this->archive_builder->finalize(true); }