More tests, filtering iterator, cleanup

This commit is contained in:
2022-10-31 02:58:34 +01:00
parent d0956f851c
commit fd2767b642
14 changed files with 340 additions and 21 deletions

View File

@ -45,12 +45,16 @@ class CsvReader implements ReaderInterface
private function loadData(array $data)
{
// FIXME parse data according to directives if present
$separator = $this->options['separator']??',';
$enclosure = $this->options['enclosure']??'"';
$escape = $this->options['escape']??"\\";
$head = str_getcsv(array_shift($data));
$this->data = [];
foreach ($data as $row) {
if ($row) {
$row = str_getcsv($row);
$row = str_getcsv($row, $separator, $enclosure, $escape);
$this->data[] = array_combine($head, $row);
}
}

View File

@ -35,8 +35,10 @@ class JsonReader implements ReaderInterface
//printf("Reached end of set at slice=%d\n", $this->currentFile);
return;
}
$flags = ($this->options['bigintAsString']??false)?JSON_BIGINT_AS_STRING:0;
$file = $this->files[$this->currentFile];
$json = @json_decode(@file_get_contents($file), true);
$json = @json_decode(@file_get_contents($file), true, flags:$flags);
$this->loadData($json);
$this->loadedFile = $this->currentFile;