Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Bad Text::CSV_XS parameter

by pcouderc (Monk)
on Apr 24, 2020 at 13:27 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 03:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found