added ignore_empty_subfields [0.24_1]
[Biblio-Isis] / scripts / dump_openisis.pl
1 #!/usr/bin/perl -w
2
3 # this utility emulates output of openisis -db "database"
4 # so you can test if perl can read your isis file
5
6 #use strict;
7 use OpenIsis;
8 use Data::Dumper;
9
10 my $db = OpenIsis::open( shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI' );
11 my $debug = shift @ARGV;
12 my $maxmfn = OpenIsis::maxRowid( $db ) || 1;
13
14 print "rows: $maxmfn\n\n";
15
16 for (my $mfn = 1; $mfn <= $maxmfn; $mfn++) {
17         print "0\t$mfn\n";
18         my $row = OpenIsis::read( $db, $mfn );
19         if ($debug)  {
20                 print STDERR Dumper($row),"\n";
21                 my $rec;
22                 foreach my $f (keys %{$row}) {
23                         foreach my $v (@{$row->{$f}}) {
24                                 push @{$rec->{$f}}, OpenIsis::subfields($v);
25                         }
26                 }
27                 print STDERR Dumper($rec),"\n";
28         }
29         foreach my $k (sort keys %{$row}) {
30                 next if ($k eq 'mfn');
31                 print "$k\t",join("\n$k\t",@{$row->{$k}}),"\n";
32         }
33         print "\n";
34 }
35