From: Don McMorris Date: Sat, 2 Aug 2008 17:18:24 +0000 (+0000) Subject: spit_csv expets subfields X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=6ee444c4929227f00b277cfffb403dbec32f635f spit_csv expets subfields --- diff --git a/spit_marc_903a_001.pl b/spit_marc_903a_001.pl new file mode 100755 index 0000000..b70b2d2 --- /dev/null +++ b/spit_marc_903a_001.pl @@ -0,0 +1,36 @@ +#!/usr/bin/perl +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'); + +foreach my $argnum ( 0 .. $#ARGV ) { + + print STDERR "Processing " . $ARGV[$argnum] . "\n"; + + my $M; + open $M, '<:utf8', $ARGV[$argnum]; + my $batch = MARC::Batch->new('XML',$M); + + $batch->strict_off(); + $batch->warnings_off(); + + while ( my $record = $batch->next() ) { + + $count++; + + print STDERR "WARNINGS: Record $count : " . join(":",@warnings) . " : continuing...\n" if ( @warnings ); + + my @my001 = $record->field('001'); + if (scalar(@my001) == 0 || scalar(@my001) > 1) { die "Wrong number of 001 tags for record $count\n"; } + my @my903 = $record->field('903'); + if (scalar(@my903) == 0 || scalar(@my903) > 1) { die "Wrong number of 903 tags for record $count\n"; } + print $my903[0]->subfield('a') . "\t" . $my001[0]->as_string() . "\n" + } + print STDERR "Processed $count records\n"; +}