modifs.mineures sans commentaires
This commit is contained in:
parent
559bc853b0
commit
5f79f1cad9
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue