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 (Archbishop) 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.