Tux / Text-CSV_XS

perl5 module for composition and decomposition of comma-separated values
17 stars 20 forks source link

Double headers when both detect_bom and headers are provided #48

Closed charsbar closed 1 year ago

charsbar commented 1 year ago

re: https://github.com/makamaka/Text-CSV/issues/63

Using the module for a command-line tool, I'm consistently setting headers => 'auto' and give the possibility to specify a detect_bom based on a command-line option.

Tests show that when both options are active, headers are read twice, which ends up skipping the first line (where real headers live) and trying to set headers from the second line.

I'd say that this behaviour is surprising and sub-optimal, although admittedly there's no indication that this should not behave this way in the docs. I'm currently working this around like this:

my $has_bom = ...;
my @csv_args = (
($has_bom ? (detect_bom => 1) : (headers => 'auto')),
...
);

If you're interested, this is a full test for this:

(snip)

The test also fails for Text::CSV_XS. Could you take a look at it when you have some time and tuits?

Tux commented 1 year ago

Fix being tested. Still needs backport to old perl versions

Tux commented 1 year ago

This commit is now being tested on all CPAN modules that depend on Text::CSV_XS. It includes the actual fix If used_by.pl also PASSes, I'll release

Tux commented 1 year ago

fixed and uploaded as 1.51