bug 2287: use defaults when needed even if CSV has correct number of columns
authorMJ Ray <mjr@phonecoop.coop>
Thu, 21 May 2009 14:27:20 +0000 (15:27 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Wed, 16 Sep 2009 21:18:56 +0000 (23:18 +0200)
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>
tools/import_borrowers.pl

index 9738f19..5d477ef 100755 (executable)
@@ -143,6 +143,12 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
             push @missing_criticals, {badparse=>1, line=>$., lineraw=>$borrowerline};
         } elsif (@columns == @columnkeys) {
             @borrower{@columnkeys} = @columns;
+            # MJR: try to fill blanks gracefully by using default values
+            foreach my $key (@criticals) {
+                if ($borrower{$key} !~ /\S/) {
+                    $borrower{$key} = $defaults{$key};
+                }
+            } 
         } else {
             # MJR: try to recover gracefully by using default values
             foreach my $key (@columnkeys) {