Bug Report
| Information |
Description |
| Version |
9.4.1 |
| PHP version |
7.2.24 |
I think there is an issue with the behavior of the $limit parameter in the delimiter_detect function.
Or at least I find it really confusing.
Example with the following csv and call to the function:
foo;bar;hello_world
42;1,2,3,4,5;true
delimiter_detect($reader, [';', ','], 1)
In this case I would expect the function to only take the first line(the header) into account. And so ; would be the delimiter with the highest count.
But it actually returns:
It happens because of the record count where condition in the statement
$stmt = (new Statement())->limit($limit)->where(static function (array $record): bool {
return count($record) > 1;
});
When counting for the , delimiter, it will skip the first line.
It makes so the delimiters are not compared to the same lines.
Because of this behavior it breaks the detection of delimiters on the header only (which is usually more consistent than other lines).
As a workaround I made my own delimiter_detect function, removing the condition on the statement and it works as expected.
Bug Report
I think there is an issue with the behavior of the
$limitparameter in thedelimiter_detectfunction.Or at least I find it really confusing.
Example with the following csv and call to the function:
In this case I would expect the function to only take the first line(the header) into account. And so
;would be the delimiter with the highest count.But it actually returns:
It happens because of the record count where condition in the statement
When counting for the
,delimiter, it will skip the first line.It makes so the delimiters are not compared to the same lines.
Because of this behavior it breaks the detection of delimiters on the header only (which is usually more consistent than other lines).
As a workaround I made my own
delimiter_detectfunction, removing the condition on the statement and it works as expected.