added -v to dump script which will display erased records and empty subfields
[Biblio-Isis] / scripts / dump_isisdb.pl
index 057cd29..c6f47ba 100755 (executable)
@@ -3,23 +3,40 @@
 use strict;
 use blib;
 
-use Biblio::Isis;
-use Data::Dumper;
+use Biblio::Isis 0.24;
+use Getopt::Std;
 
-my $isisdb = shift @ARGV || '/data/isis_data/ps/LIBRI/LIBRI',
-my $debug = shift @ARGV;
+BEGIN {
+       eval "use Data::Dump";
+
+       if (! $@) {
+               *Dumper = *Data::Dump::dump;
+       } else {
+               use Data::Dumper;
+       }
+}
+
+my %opt;
+getopts('do:l:v', \%opt);
+
+my $isisdb = shift @ARGV || die "usage: $0 [-v] [-o offset] [-l limit] [-d] /path/to/isis/BIBL\n";
 
 my $isis = Biblio::Isis->new (
        isisdb => $isisdb,
-       debug => $debug,
-       include_deleted => 1,
+       debug => $opt{'d'} ? 2 : 0,
+       include_deleted => $opt{'v'},
 #      read_fdt => 1,
+       ignore_empty_subfields => $opt{'v'} ? 0 : 1,
 );
 
 print "rows: ",$isis->count,"\n\n";
 
-for(my $mfn = 1; $mfn <= $isis->count; $mfn++) {
-       print STDERR Dumper($isis->to_hash($mfn)),"\n" if ($debug);
+my $min = $opt{o} || 1;
+my $max = $isis->count;
+$max = ( $min + $opt{l} - 1 ) if ($opt{l});
+
+for my $mfn ($min .. $max) {
+       print STDERR Dumper($isis->to_hash($mfn)),"\n" if ($opt{'d'});
        print $isis->to_ascii($mfn),"\n";
 
 }