From: Ben Ostrowsky Date: Tue, 5 Jan 2010 14:30:27 +0000 (+0000) Subject: Polaris patron extractor, first working version X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=ab8df89476cd0f2849a219a2015744e3e0a32698 Polaris patron extractor, first working version --- diff --git a/polaris/extract_patrons b/polaris/extract_patrons new file mode 100755 index 0000000..840028d --- /dev/null +++ b/polaris/extract_patrons @@ -0,0 +1,42 @@ +#!/usr/bin/perl -w + +# Polaris exports patrons in MARC format. This script turns the data into a TSV that can be imported with \copy. + +use strict; +use MARC::Record; +use MARC::File::USMARC; +use Equinox::Migration::SubfieldMapper 1.004; + +my $file = MARC::File::USMARC->in("PATRONS.mrc"); +my $serial = 0; +my @modlist = qw( multi ignoremulti bib required ); # Not sure what these do, but I'll cargo-cult it for now +my $mapfile = 'patron.map'; + +# initialize map and taglist +my $sfmap = Equinox::Migration::SubfieldMapper->new( file => $mapfile, mods => \@modlist ); + +my $temp = $sfmap->tags(); # $temp is an arrayref +my @fields = sort @$temp; + +while ( my $marc = $file->next() ) { + # Preliminaries + print $serial++ . "\t"; + print $marc->leader() . "\t"; + print $marc->field('001')->data() . "\t"; + print $marc->field('005')->data() . "\t"; + print $marc->field('008')->data() . "\t"; + # Fields and subfields beyond the preliminaries + foreach my $tag (@fields) { + my $temp = $sfmap->subfields($tag); + foreach my $sf (sort @$temp) { + if ($sfmap->has($tag, $sf)) { + print $marc->subfield($tag, $sf); + } + print "\t"; + } + } + print "\n"; +} + +$file->close(); +undef $file;