X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=extract_loadset;h=a4f41accb46024e3c59d37c41c042c06ffcf704c;hp=9b0be3c68e23dddc9d61e05d21f69183da4eb71a;hb=6891bd6d84b8289beabbf609643deb75467a3026;hpb=072efb63a94c69c32a84c97b92d1d30441ab72f2 diff --git a/extract_loadset b/extract_loadset old mode 100644 new mode 100755 index 9b0be3c..a4f41ac --- a/extract_loadset +++ b/extract_loadset @@ -8,12 +8,24 @@ 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 () { + my ($lead,$sub) = split /\t/; + $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 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 ('prefix') + for my $key ('output', 'lowerbound', 'input') { push @missing, $key unless $c->{$key} } if (@missing) { print "Required option: ", join(', ', @missing), " missing!\n"; @@ -40,7 +59,13 @@ sub initialize { sub show_help { print <