modifs.mineures sans commentaires

This commit is contained in:
Jephté Clain 2024-07-01 11:46:25 +04:00
parent 559bc853b0
commit 5f79f1cad9
1 changed files with 7 additions and 0 deletions

View File

@ -9,12 +9,19 @@ class CsvReader extends AbstractReader {
function __construct($input, ?array $params=null) { function __construct($input, ?array $params=null) {
parent::__construct($input, $params); parent::__construct($input, $params);
$this->csvFlavour = $params["csv_flavour"] ?? null; $this->csvFlavour = $params["csv_flavour"] ?? null;
$this->inputEncoding = $params["input_encoding"] ?? null;
} }
protected ?string $csvFlavour; protected ?string $csvFlavour;
protected ?string $inputEncoding;
function getIterator() { function getIterator() {
$reader = new FileReader($this->input); $reader = new FileReader($this->input);
$inputEncoding = $this->inputEncoding;
if ($inputEncoding !== null) {
$reader->appendFilter("convert.iconv.$inputEncoding.utf-8");
}
$reader->setCsvFlavour($this->csvFlavour); $reader->setCsvFlavour($this->csvFlavour);
while (($row = $reader->fgetcsv()) !== null) { while (($row = $reader->fgetcsv()) !== null) {
foreach ($row as &$col) { foreach ($row as &$col) {