kenahoo / Perl-Parse-CSV

Highly flexible CSV parser for large files
0 stars 4 forks source link

Doesn't handle BOM #8

Open pjlsergeant opened 4 years ago

pjlsergeant commented 4 years ago

If a CSV file leads with a BOM (such as Excel will produce with CSV UTF8 output), then this gets sucked into the header. If you were using Text::CSV_XS directly, you'd pass detect_bom into the header method (it's not an argument to the constructor), however, your module never uses that. As such, this module can't be used with many Excel-produced CSV files.

use Parse::CSV; my $line = Parse::CSV->new( file => 'bad.csv', names => 1 )->fetch; my ($bad_key) = grep { /domain/ } keys %$line; use Data::Dumper; print Dumper( $bad_key );

prints:

$VAR1 = "\x{feff}domain";

on the attached CSV (zipped because Github is bad).

bad.csv.zip

kenahoo commented 4 years ago

Thanks Peter, I'll see if I can get this cleared up.