[open-ils-commits] r341 - conifer/trunk/tools/migration-scripts (dbs)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Apr 16 15:12:39 EDT 2009
Author: dbs
Date: 2009-04-16 15:12:35 -0400 (Thu, 16 Apr 2009)
New Revision: 341
Modified:
conifer/trunk/tools/migration-scripts/fixURIs.pl
Log:
miker says MARC::Batch would be more efficient; okay.
Baby steps towards pipeline processing.
Modified: conifer/trunk/tools/migration-scripts/fixURIs.pl
===================================================================
--- conifer/trunk/tools/migration-scripts/fixURIs.pl 2009-04-16 18:33:42 UTC (rev 340)
+++ conifer/trunk/tools/migration-scripts/fixURIs.pl 2009-04-16 19:12:35 UTC (rev 341)
@@ -1,7 +1,11 @@
#!/usr/bin/perl -w
use strict;
+use warnings;
+
+use Error qw/:try/;
use Getopt::Long;
use MARC::File::XML( BinaryEncoding => 'utf8', RecordFormat => 'USMARC' );
+use MARC::Batch;
# Clean up URIs from MARCXML records prior to batch ingest
# * If we detect a proxy URL:
@@ -23,11 +27,16 @@
exit();
}
-my $input = MARC::File::XML->in( $input_file );
+my $input = new MARC::Batch( 'XML', $input_file );
+$input->strict_off();
my $output = MARC::File::XML->out( $output_file );
my ($touched, $url_cnt, $ind1_cnt, $ind2_cnt, $sub9_cnt) = (0, 0, 0, 0, 0);
-while (my $marc = $input->next()) {
+my $marc;
+while ( try { $marc = $input->next() } otherwise { $marc = -1 } ) {
+ # Skip the record if we couldn't even decode it
+ next if ($marc == -1);
+
my $edited = 0;
my @uri_fields = $marc->field('856');
foreach my $uri (@uri_fields) {
More information about the open-ils-commits
mailing list