From 84e5ec94b86affe2411d59699500923683321adf Mon Sep 17 00:00:00 2001 From: Don McMorris Date: Thu, 31 Jul 2008 20:47:00 +0000 Subject: [PATCH] spit tlc marc holdings --- spit_tlc_marc_holdings.pl | 69 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-) create mode 100755 spit_tlc_marc_holdings.pl diff --git a/spit_tlc_marc_holdings.pl b/spit_tlc_marc_holdings.pl new file mode 100755 index 0000000..c0f7fae --- /dev/null +++ b/spit_tlc_marc_holdings.pl @@ -0,0 +1,69 @@ +#!/usr/bin/perl +use open ':utf8'; +use MARC::Batch; +use MARC::File::XML ( BinaryEncoding => 'utf-8' ); +use MARC::Field; +use Unicode::Normalize; + +my $count = 0; + +binmode(STDOUT, ':utf8'); +binmode(STDIN, ':utf8'); + +print join("\t", + "bib id", + "library", + "barcode", + "current location", + "home location", + "call number", + "item type", + "acq date", + "price", + "circulate flag", + "total charges", + "cat1", + "cat2" +) . "\n"; + +foreach my $argnum ( 0 .. $#ARGV ) { + + print STDERR "Processing " . $ARGV[$argnum] . "\n"; + + my $batch = MARC::Batch->new('XML',$ARGV[$argnum]); + $batch->strict_off(); + $batch->warnings_off(); + + while ( my $record = $batch->next() ) { + + $count++; + + print STDERR "WARNINGS: Record $count : " . join(":",@warnings) . " : continuing...\n" if ( @warnings ); + my $my_903a = $record->field('903')->subfield('a'); # target bib id's here + my @tags = $record->field('949'); + foreach my $tag ( @tags ) { + print join("\t", + $my_903a, # bib id + $tag->subfield('a') || '', # collection code + $tag->subfield('b') || '', # prefix + $tag->subfield('c') || '', # call number + $tag->subfield('d') || '', # cutter number + $tag->subfield('g') || '', # barcode + $tag->subfield('h') || '', # serial year + $tag->subfield('i') || '', # volume number + $tag->subfield('j') || '', # part subdivision 1 + $tag->subfield('k') || '', # part subdivision 2 + $tag->subfield('l') || '', # part subdivision 3 + $tag->subfield('m') || '', # part subdivision 4 + $tag->subfield('n') || '', # copy number + $tag->subfield('o') || '', # accession number + $tag->subfield('p') || '', # price + $tag->subfield('q') || '', # condition + $tag->subfield('5') || '', # magnetic media + $tag->subfield('7') || '' # checkin-in/check-out note + ) . "\n"; + } + + } + print STDERR "Processed $count records\n"; +} -- 1.7.2.5