Closed XSven closed 3 months ago
is_missing ()
and bind_colums ()
explain why, but also state thtat strict
is checked. There might be a conflict in the code for non-streaming parsing (parse ()
)
strict
can be useful, but it proves to be a pita when implementing that for edge cases
I also realise that using parse ()
in combination with column_names ()
is implicitely unsupported, as parse ()
always returns a list of values and never a hash. So maybe just document that this situation would never trigger the expected error.
column_names
is to work together with getline_hr
. parse
is more like getline
, which also ignores column_names
.
What _could* be done - which IMHO would be a good idea - is to make column_names
implicitely set the expected number of fields to the number of supplied columns as if a first line was already read (which is not the case: strict
bases its failures on the first data-line read.
Note that in your example
$csv->column_names (qw( A B C ));
$csv->parse ("a|b|c");
$csv->parse ("a|b");
will fire an error on that last parse
Ok, try ea3310c6272566891d108323f4204392e3c7cd5d
https://github.com/Tux/Text-CSV_XS/commit/ea3310c6272566891d108323f4204392e3c7cd5d works as expected. Thx again for improving things so quickly! This issue can be closed from my perspective. Any indication when you will provide a new CPAN release?
Thanks for walking the line and quick feedback. It motivates
There is another
strict
mode related use case: If I set 3column_names ()
instrict
mode$csv->column_names (qw( A B C ));
and then
parse ()
only 2$csv->parse ('a|b');
I am expecting an exception!