Hi there monks
The last couple of days I've been playing around with Text::CSV_XS to import some csv data. Which goes quite well up to the point where I encounter special characters.
I've made myself a test file:
and try to parse that with the following code:Naam,Adres,Woonplaats Peter,Liër,ôlsten
which results in the following output:#! /usr/bin/perl -w use strict; use Text::CSV_XS qw( csv ); use Data::Dumper; my @rows; open my $FH, "<", "./test2.csv" or die "./test.csv $!"; my $aoh = csv( in => $FH, headers => 'auto' ); close $FH; print Dumper($aoh);
I tried to resolv this by putting an encoding on the file open like "<:encoding(UTF-8)" or by adding "encoding => 'UTF-8' to the csv parameters. Neither have the desired effect.$VAR1 = [ { 'Woonplaats' => "\x{f4}lsten", 'Adres' => "Li\x{eb}r", 'Naam' => 'Peter' } ];
Perhaps a complete new problem, allthough I think it has something to do with it: The stream I need to parse (originally) has some jibbrish at the start. I think that is a BOM. So I tried to put "detect_bom => 1" to the csv parameters as the man pages suggests. This results in an error:
# CSV_XS ERROR: 1000 - INI - Unknown attribute 'detect_bom' @ rec 0 po +s 0 INI - Unknown attribute 'detect_bom' at ./parse.pl line 12. shell returned 25
Could anyone shine a light on this for me?
Peter
In reply to Text::CSV_XS and encoding by PeterKaagman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |