[open-ils-commits] r11945 - trunk/Open-ILS/src/extras/import

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Jan 25 10:53:10 EST 2009


Author: miker
Date: 2009-01-25 10:53:08 -0500 (Sun, 25 Jan 2009)
New Revision: 11945

Modified:
   trunk/Open-ILS/src/extras/import/marc_add_ids
Log:
add MARCXML cleanup, quiet mode, current count output and newline stripping for marc output

Modified: trunk/Open-ILS/src/extras/import/marc_add_ids
===================================================================
--- trunk/Open-ILS/src/extras/import/marc_add_ids	2009-01-25 03:03:10 UTC (rev 11944)
+++ trunk/Open-ILS/src/extras/import/marc_add_ids	2009-01-25 15:53:08 UTC (rev 11945)
@@ -15,11 +15,15 @@
 binmode(STDIN, ':utf8');
 binmode(STDOUT, ':utf8');
 
+$| = 1;
+
 my ($delim, @fields) = (' \| ');
+my $quiet = 0;
 my $set_001_003 = 0;
 my $repository_code = 'Evergreen';
 my $set_as_deleted = 0;
 GetOptions(
+	'quiet'	=> \$quiet,
 	'delimiter=s'	=> \$delim,
 	'field=s'	=> \@fields,
     'set_001_003'   => \$set_001_003,
@@ -51,6 +55,8 @@
 	}
 
 	next unless ($partlist{marc});
+    next unless ($partlist{id} =~ /^\d+$/);
+    $partlist{marc} =~ s/<(\/?)marc:/<$1/go;
 
 	try {
 		my $r = MARC::Record->new_from_xml($partlist{marc});
@@ -89,9 +95,14 @@
             }
         }
 
-		print $r->as_xml_record;
+		my $x = $r->as_xml_record;
+        $x =~ s/\n//gso;
+        print $x."\n";
+        $count++;
+        print STDERR "\r$count" unless ($quiet || $count % 100);
+
 	} otherwise {
-		warn "failed on record $., $partlist{marc}, for $@\n";
+		warn "failed on record $., $partlist{marc}, for $@\n" if (!$quiet);
 	};
 }
 



More information about the open-ils-commits mailing list