=================================================================== RCS file: /cvs/pta/pta_import.pl,v retrieving revision 1.17 retrieving revision 1.18 diff -u -p -r1.17 -r1.18 --- pta/pta_import.pl 2020/11/19 23:55:50 1.17 +++ pta/pta_import.pl 2020/11/22 00:02:06 1.18 @@ -156,7 +156,7 @@ $banks{$account_name} or die "unknown accountname: $ac # Parse the configuration file. my $fn = "import_" . $account_name . ".txt"; open my $in, '<', $fn or die "$fn: $!"; -my ($csv_account, $delim, $header, @compiled); +my ($csv_account, $delim, $header, $quote, @compiled); while (<$in>) { chomp; next if /^(?:#|$)/; @@ -176,6 +176,11 @@ while (<$in>) { $header = $1; next; } + if (/^QUOTE\s+(\S)$/) { + $quote and die "duplicate QUOTE line: $1"; + $quote = $1; + next; + } $delim or die "no DELIM line in $fn"; s/^(.*)$delim\s+(\d+)\s+(\S+)// or die "$fn import parse error: $line"; @@ -199,7 +204,13 @@ while (<>) { undef $header; next; } - my @fields = split /$delim/, $line; + my $copy_line = $line; + my @fields; + if ($quote) { + push @fields, $1 while $copy_line =~ s/$quote([^$quote]*)$quote$delim?//; + } else { + @fields = split /$delim/, $line; + } my $matches = 0; my ($account, $booking); foreach my $selector (@compiled) {