X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=extract_loadset;h=43b2e5277c1abf5391e86f98944e9d4e7b73b0d1;hp=4e3296e4964cf9749fd4229e1148e6030b8ddce1;hb=1a3ca3ba98d644892f5fbad6084e515736394452;hpb=07a7c7a61c96870cac6a20d3019b063323c12e33 diff --git a/extract_loadset b/extract_loadset index 4e3296e..43b2e52 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'; @@ -8,12 +25,25 @@ use Getopt::Long; my $conf = {}; # configuration hashref initialize($conf); -open FP, '<', shift or die "Can't open input file: $!\n"; - +# build exclusion hash +open FP, '<', shift or die "Can't open matchset file: $!\n"; +my %exclude = (); while () { + chomp; my ($lead,$sub) = split /\t/; - print $sub if $sub > 6999999) + $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->{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+){help}); + $conf->{tag} = $conf->{tag} || 903; + $conf->{subfield} = $conf->{subfield} || 'a'; + my @keys = keys %{$c}; show_help() unless (@ARGV and @keys); - for my $key ('output', 'filter') + for my $key ('output', 'lowerbound', 'input') { push @missing, $key unless $c->{$key} } if (@missing) { print "Required option: ", join(', ', @missing), " missing!\n"; @@ -42,10 +78,13 @@ sub initialize { sub show_help { print <