X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=extract_loadset;h=61326bdd0c575e3dfd069b18139926353c63aa8b;hp=b85ef19ecc4bb0e8bd9daacd125daeae73e9901b;hb=10de3f4ac4bda540279413d818b15740ade85788;hpb=2ec12a6854276ff738cbd06a87c68bb97e479868 diff --git a/extract_loadset b/extract_loadset index b85ef19..61326bd 100755 --- a/extract_loadset +++ b/extract_loadset @@ -1,4 +1,21 @@ #!/usr/bin/perl + +# Copyright 2009-2012, Equinox Software, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + use strict; use warnings; use open ':utf8'; @@ -12,17 +29,24 @@ initialize($conf); open FP, '<', shift or die "Can't open matchset file: $!\n"; my %exclude = (); while () { + chomp; my ($lead,$sub) = split /\t/; + $sub =~ s/\s//g; # any whitespace is extraneous $exclude{$sub} = 1 unless ($sub < $conf->{lowerbound}); } close FP; # strip exclusions from marcxml file -open MI, '<', $conf->{marc} or die "Can't open input file: $!\n"; +open MI, '<', $conf->{input} or die "Can't open input file: $!\n"; open MO, '>', $conf->{output} or die "Can't open output file: $!\n"; while () { - m/tag="$conf->{tag}",+?(\d+){tag}".+?(\d+){reverse}) { + print MO if $exclude{$1}; + } else { + print MO unless $exclude{$1}; + } } @@ -34,11 +58,12 @@ sub initialize { binmode(STDIN, ':utf8'); my $rc = GetOptions( $c, - 'lowerbound|l=i' + 'lowerbound|l=i', 'input|i=s', 'output|o=s', 'tag|t=i', 'subfield|s=s', + 'reverse|r', 'help|h', ); show_help() unless $rc; @@ -59,11 +84,14 @@ sub initialize { sub show_help { print <