=================================================================== RCS file: /cvs/pta/pta_import.pl,v retrieving revision 1.17 retrieving revision 1.19 diff -u -p -r1.17 -r1.19 --- pta/pta_import.pl 2020/11/19 23:55:50 1.17 +++ pta/pta_import.pl 2020/11/22 01:48:36 1.19 @@ -100,7 +100,7 @@ sub import_sparkasse_camt ($$$) { sub import_wellsfargo ($$$) { my ($account, $csv_account, $line) = @_; $line =~ - m#^"(\d+)/(\d+)/(\d+)","(-?\d+\.\d+)","\*","","(.*?)"$# or + m#^"(\d+)/(\d+)/(\d+)","(-?\d+\.\d+)","\*",".*","(.*?)"$# or die "parse error: $line" ; my ($month, $day, $year, $amount, $description) = ($1, $2, $3, $4, $5); @@ -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) {