From: Darold Gilles Date: Tue, 30 Sep 2014 19:04:30 +0000 (+0200) Subject: Enable allow_loose_quotes and undef escape_char in Text::CSV_XS call to fix CSV forma... X-Git-Tag: v6.2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=55b7d96075df1e88fa8d525158247634abe9d180;p=pgbadger Enable allow_loose_quotes and undef escape_char in Text::CSV_XS call to fix CSV format error when fields have quote inside an unquoted field. Thanks to Josh Berkus for the report. --- diff --git a/pgbadger b/pgbadger index fc2d7ae..6c35908 100755 --- a/pgbadger +++ b/pgbadger @@ -1932,7 +1932,15 @@ sub process_file if ($format eq 'csv') { require Text::CSV_XS; - my $csv = Text::CSV_XS->new({binary => 1, eol => $/, sep_char => $csv_sep_char}); + my $csv = Text::CSV_XS->new( + { + binary => 1, + eol => $/, + sep_char => $csv_sep_char, + allow_loose_quotes => 1, + escape_char => undef + } + ); # Parse csvlog lines while (my $row = $csv->getline($lfile)) { @@ -2019,7 +2027,7 @@ sub process_file } } if (!$getout) { - $csv->eof or warn "FATAL: cannot use CSV, " . $csv->error_diag() . "\n"; + $csv->eof or warn "FATAL: cannot use CSV on $logfile, " . $csv->error_diag() . "\n"; } }