Skip to content

Commit

Permalink
Ingestion optimization (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
thierrydallacroce authored Mar 12, 2020
1 parent 7dbf9d4 commit 7bedbf4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/Parser/Csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public function getRecord()
return $record;
}

public function getRecords() : array
{
$records = [];
while ($record = $this->getRecord()) {
$records[] = $record;
}
return $records;
}

public function reset()
{
$this->field = "";
Expand Down
5 changes: 1 addition & 4 deletions test/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ public function test()
$parser->feed(file_get_contents(__DIR__ . "/data/countries.csv"));
$parser->finish();

$records = [];
while ($record = $parser->getRecord()) {
$records[] = $record;
}
$records = $parser->getRecords();

$this->assertEquals(5, count($records));
}
Expand Down

0 comments on commit 7bedbf4

Please sign in to comment.