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