Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Bad Text::CSV_XS parameter

by pcouderc (Monk)
on Apr 24, 2020 at 13:27 UTC ( #11116018=note: print w/replies, xml ) Need Help??


in reply to Re: Bad Text::CSV_XS parameter
in thread Bad Text::CSV_XS parameter

My file is:
hexdump -C ddd.CSV 00000000 ef bb bf 22 30 31 30 31 32 30 31 39 22 2c 22 31 |..."01012 +019","1| 00000010 38 31 36 22 0a 0a 0a |816"...| 00000017

Replies are listed 'Best First'.
Re^3: Bad Text::CSV_XS parameter
by hippo (Bishop) on Apr 24, 2020 at 13:56 UTC

    If you have a BOM you have to deal with it: BOM

      Thank you, you got it !
      if I remove the BOM with vim, it works...

      Thank you very much, even if I cannot use "detect_bom => 1" in this case as there is no header...

        You can use header () even if your CSV does not have a header, if only to detect BOM, eol, and SEP.

        open my $fh, "<", "file.csv" or die "$!"; my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1 }); $csv->header ($fh, { bom => 1, set_column_names => 0 }); while (my $row = $csv->getline ($fh)) { # ... }

        Enjoy, Have FUN! H.Merijn
        A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11116018]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-05-19 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (72 votes). Check out past polls.

    Notices?