The data:# CSV_PP ERROR: 2023 - EIQ - QUO character not allowed @ rec 4 pos 105 + field 7
Code used:147;lakjfh lkjsfh ehjd;134-324-730 31;291;24.04.2020;15 000,00;severo- +vostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;347 +636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sber +bank g. magadan;896868986;98375423895239529987;;96764128476876487264 148;lkjf fdkas fa;123-105-878 17;1;23.04.2020;15 000,00;severo-vostocn +oe otdelenie № 8645 pao "sberbank rossii";4243972345;347636334; +23452347344633423542;severo-vostocnoe otdelenie N8645 pao sberbank g. + magadan;896868986;98375423895239529987;;23236726352762456346 149;sdfg gdsgsdhsds shsddf;104-424-501 02;146;20.04.2020;15 000,00;sev +ero-vostocnoe otdelenie pao "sberbank";4243972345;347636334;234523473 +44633423542;severo-vostocnoe otdelenie N8645 pao sberbank g. magadan; +896868986;98375423895239529987;;23236726352762456346 150;dfgsdfgsdg sdgsdgsdgsdg sdfgdsgs;095-504-250 68;68;17.04.2020;15 0 +00,00;"aziatsko-tihookeanskiy bank" (pao) g. blagovesensk;3473446334; +280101001;23452344637833423542;"aziatsko-tihookeanskiy bank" (pao) g. + blagovesensk;098676868;9837542asdfaas529987;;23236726352762456346 151;sdfgds fdsgd ssdgsd;108-437-022 37;258;23.04.2020;15 000,00;severo +-vostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;34 +7636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sbe +rbank g. magadan;896868986;98375423895239529987;;23236726352762456346 152;bgerghe egertge ertgeer;074-073-043 41;128;20.04.2020;15 000,00;se +vero-vostocnoe otdelenie № 8645 pao "sberbank rossii";424397234 +5;347636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao + sberbank g. magadan;896868986;98375423895239529987;;2323672635276245 +6346 153;lskdjfa sflaskjfd aslkdfjaslf;151-533-432 32;33;22.04.2020;15 000, +00;severo-vostocnoe otdelenie № 8645 pao "sberbank rossii";4243 +972345;347636334;23452347344633423542;severo-vostocnoe otdelenie N864 +5 pao sberbank g. magadan;896868986;98375423895239529987;;23236726352 +762456346 154;lasfnf fsdafasdfas afs;134-092-549 45;21;23.04.2020;5 000,00;sever +o-vostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;3 +47636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sb +erbank g. magadan;896868986;98375423895239529987;;2323672635276245634 +6 155;asdfasf asdf asdfasfd;110-497-874 55;50;24.04.2020;15 000,00;sever +o-vostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;3 +47636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sb +erbank g. magadan;896868986;98375423895239529987;;2323672635276245634 +6 156;sadfasf asdf asdfas;456-978-244 89;117;17.04.2020;15 000,00;severo +-vostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;34 +7636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sbe +rbank g. magadan;896868986;98375423895239529987;;23236726352762456346 157;asdfasfwer asfdasfs sadf;139-220-696 59;26;21.04.2020;15 000,00;se +vero-vostocnoe otdelenie № 8645 pao "sberbank rossii";424397234 +5;347636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao + sberbank g. magadan;896868986;98375423895239529987;;2323672635276245 +6346 158;lksj ljlkjlkjl lkjljlk;133-087-587 59;262;23.04.2020;15 000,00;sev +ero-vostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345 +;347636334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao +sberbank g. magadan;896868986;98375423895239529987;;23236726352762456 +346 159;fghd g dfghdhdfgh;141-008-388 12;241;22.04.2020;30 000,00;severo-v +ostocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;3476 +36334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sberb +ank g. magadan;896868986;98375423895239529987;;23236726352762456346 160;lkkljh kljhk kjh;123-650-136 21;20;20.04.2020;15 000,00;severo-vos +tocnoe otdelenie № 8645 pao "sberbank rossii";4243972345;347636 +334;23452347344633423542;severo-vostocnoe otdelenie N8645 pao sberban +k g. magadan;896868986;98375423895239529987;;23236726352762456346 161;sdgfd sgdsgdsg sdfgds;154-978-292 22;93;17.04.2020;15 000,00;sever +o-vostocnoe otdelenie 8645 pao sberbank;4243972345;347636334;23452347 +344633423542;severo-vostocnoe otdelenie N8645 pao sberbank g. magadan +;896868986;98375423895239529987;;23236726352762456346 162;lkdasj alsdfka sflas;112-031-647 83;61;17.04.2020;15 000,00;severo +-vostocnoe otdelenie 8645 pao sberbank;7707083893;347636334;234523473 +44633423542;severo-vostocnoe otdelenie N8645 pao sberbank g. magadan; +896868986;89686898634243972345;;23236726352762456346
Command to execute:my $codepage = 'utf8'; use utf8; binmode(STDOUT, ":$codepage"); binmode(STDOIN, ":$codepage"); use Text::CSV; my $fileTable = shift; my $CSV_H = Text::CSV->new({ sep_char=>";", binary=>1, blank_is_undef=>1, empty_is_undef=>1, allow_whitespace=>0, allow_loose_quotes=>1 }); if(open my $TBL_H, "<:encoding($codepage)", "$fileTable"){ while(my $row = $CSV_H->getline($TBL_H)){ } $CSV_H->eof or $CSV_H->error_diag(); close $TBL_H; }
csv-prog.pl csv-file.csv
I realize, that this csv text is not completeley valid, but there has to be a way to bypass the error and parse the file anyway. Otherwise, I would have to write my own csv library, which I would like to avoid.
and added a function:$CSV_H->callbacks(error=>\&onerror);
, but it doesn't seem to work. None of the print statements from the sub have put anything out to the screen. There was no output.sub onerror{ print '=' x 100, "\n"; printf "ERROR_INPUT: %s\n", $CSV_H->error_input(); printf "EOF: %s\n", ($CSV_H->eof)?('EOF'):('ERROR'); }
Now, I am trying to figure out an other issue:
In error handler callback, I've fixed the string, which was passed by the error_input() method, but I cannot figure out how to pass the fixed string back to the input, so it is returned back to the loop for reparsing or returning an already reparsed string back to the loop from the callback?
How to return the fixed result from the callback to the working loop?
In reply to problem with csv parsing by igoryonya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |