From 8df3fe40b8e434ffd47a298bef845645ab480f86 Mon Sep 17 00:00:00 2001 From: dbs Date: Sun, 19 Apr 2009 21:20:57 +0000 Subject: [PATCH] Fix a few common yaz-marcdump conversion to XML errors git-svn-id: svn://svn.open-ils.org/ILS-Contrib/conifer/trunk@358 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- tools/migration-scripts/fix_bad_marcxml.pl | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tools/migration-scripts/fix_bad_marcxml.pl b/tools/migration-scripts/fix_bad_marcxml.pl index 9b202c6c44..44a0f9a0e3 100644 --- a/tools/migration-scripts/fix_bad_marcxml.pl +++ b/tools/migration-scripts/fix_bad_marcxml.pl @@ -3,19 +3,20 @@ use strict; use warnings; foreach my $file (@ARGV) { - clean_empty_datafields($file); + process_file($file); } -sub clean_empty_datafields { +sub process_file { my $file = shift; # Empty datafields anger MARC::File::XML open(FH, '<', $file) or die $!; open(CLEAN, '>', "$file.new"); - my ($trim, $lastline) = (0, ''); + my ($trim, $lastline, $lineno) = (0, '', 1); while () { if ($_ =~ m## and $lastline =~ m# + # In subtitle "sports" appears as " + # ort + # . + # + # + # This will at least enable MARC::File::XML to process it: + if ($_ =~ m##o) { + print STDERR "Bad subfield code \" at line $lineno of file $file\n"; + $_ =~ s{}{}o; + } elsif ($_ =~ m##o) { + print STDERR "Bad subfield code < at line $lineno of file $file\n"; + $_ =~ s{}{}o; + } $lastline = $_; + $lineno++; } print CLEAN $lastline; -- 2.11.0