Add 020 cleanup to springer fixes while we're at it
authorDan Scott <dscott@laurentian.ca>
Sun, 18 Jan 2015 17:20:36 +0000 (12:20 -0500)
committerDan Scott <dscott@laurentian.ca>
Sun, 18 Jan 2015 17:20:36 +0000 (12:20 -0500)
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/sql/Pg/fix_old_springer.sql

index cef309f..42a2f44 100644 (file)
@@ -29,6 +29,21 @@ foreach my $fate (@fates) {
     $fate->update($data);
 }
 
+# Cleanup ISBNs that had silly leading spaces prepended
+my @isbntags = $record->field('020');
+foreach my $isbntag (@isbntags) {
+    my $rawisbn = $isbntag->subfield('a');
+    next unless $rawisbn;
+    $rawisbn =~ s{^\s*(\S+)\s*$}{$1};
+    my ($isbn, $rest) = split(/ /, $rawisbn, 2);
+    if ($rawisbn ne $isbn) {
+        $isbntag->update('a', $isbn);
+    }
+    if ($rest and $isbntag->subfield('q') ne $rest) {
+        $isbntag->update('q', $rest);
+    }
+}
+
 # Add explicit publisher relator code
 my @added = $record->field('710');
 foreach my $entry (@added) {