From b1e8ce0318600a4a0458a0b7e822716d47905f9d Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 25 Jan 2009 15:53:08 +0000 Subject: [PATCH] add MARCXML cleanup, quiet mode, current count output and newline stripping for marc output git-svn-id: svn://svn.open-ils.org/ILS/trunk@11945 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/extras/import/marc_add_ids | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/extras/import/marc_add_ids b/Open-ILS/src/extras/import/marc_add_ids index 600caa8624..03503dd57a 100755 --- a/Open-ILS/src/extras/import/marc_add_ids +++ b/Open-ILS/src/extras/import/marc_add_ids @@ -15,11 +15,15 @@ MARC::Charset->ignore_errors(1); 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 @@ while (<>) { } 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 @@ while (<>) { } } - 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); }; } -- 2.11.0