That is the hard way to get neat errors. Just add auto_diag => 2

Another approach might be to use csv-check and get the options right before you go for the real thing:

$ csv-check -v1 test.ssv
Checked test.ssv with csv-check 2.05
using Text::CSV_XS 1.42 with perl 5.30.0 and Unicode 12.1.0
test.ssv record 1 at line 1/104 - 2034 - EIF - Loose unescaped quote
    |147;lakjfh lkjsfh ehjd;134-324-730 31;291;24.04.2020;15 000,00;severo-vostocnoe otdelenie \x{02116} 8645 pao "sberbank rossii";4243972345;347636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sberbank g. magadan;896868986;98375423895239529987;;96764128476876487264\n|
    |                                                                                                             ▲                                                                                                                                                                          |
# CSV_XS ERROR: 2034 - EIF - Loose unescaped quote @ rec 0 pos 104 field 2

$ csv-check -v1 test.ssv --allow-loose-quotes
Checked test.ssv with csv-check 2.05
using Text::CSV_XS 1.42 with perl 5.30.0 and Unicode 12.1.0
OK: rows: 16, columns: 2
    sep = <,>, quo = <">, bin = <1>, eol = <"\n">

Once you get the options so that you are able to parse your (invalid) data, show the used attributes with -L:

$ csv-check -v1 test.ssv --allow-loose-quotes -L allow_loose_escapes : 0 allow_loose_quotes : 1 allow_unquoted_escape : 0 allow_whitespace : 0 always_quote : 0 auto_diag : 1 binary : 1 blank_is_undef : 0 callbacks : (undef) decode_utf8 : 1 diag_verbose : 0 empty_is_undef : 0 eol : escape_char : " escape_null : 1 formula : diag keep_meta_info : 1 quote : (undef) quote_binary : 1 quote_char : " quote_empty : 0 quote_space : 1 sep : (undef) sep_char : strict : 0 types : (undef) undef_str : (undef) verbatim : 0

Or just show the options that changed the defaults (note that csv-check sets some sane attributes that are not default):

$ csv-check -v1 test.ssv --allow-loose-quotes -X allow_loose_quotes : 1 auto_diag : 1 binary : 1 formula : diag keep_meta_info : 1

So, your code would now be:

use Text::CSV_XS; # Text::CSV_XS is much faster that Text::CSV my $fileTable = shift; my $CSV_H = Text::CSV_XS->new ({ sep_char => ";", binary => 1, blank_is_undef => 1, empty_is_undef => 1, allow_whitespace => 0, allow_loose_quotes => 1, # Should work. If not, maybe a bug in Tex +t::CSV auto_diag => 2, # Added });

Enjoy, Have FUN! H.Merijn

In reply to Re^3: problem with csv parsing by Tux
in thread problem with csv parsing by igoryonya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.