"i'm working" output
[migration-tools.git] / extract_holdings
index 8415c6a..b411540 100755 (executable)
@@ -6,15 +6,17 @@ use XML::Twig;
 use YAML;
 use JSON;
 
-my $marcxml = shift;
+my $marcxml = shift || help();
 
 open HOLDINGS, '>', "holdings";
 open X, '>', "holdings.x";
 open Z, '>', "holdings.z";
 open ALL852, '>', "holdings.all852";
 
+$| = 1;
 my $holdings = {};
 my $copyid = 0;
+my $count = 0;
 my %all852 = ( x => {}, z => {} ); # hash of all subfields in all 852s
 
 my $t = XML::Twig->new( twig_handlers => { record => \&record } );
@@ -34,6 +36,7 @@ sub record {
     for my $copy (@{$holdings->{copies}})
       { print_reports($copy) }
     $r->purge;
+    $count++; print "\r$count";
 }
 
 sub process_datafields {
@@ -87,3 +90,11 @@ sub print_reports {
     print HOLDINGS join("\t", $holdings->{id}, $copy->{copyid},
                         $copy->{b}, $copy->{p}, $copy->{h}, $copy->{9}), "\n";
 }
+
+
+sub help {
+    print <<HELP;
+Usage is: extract_holdings MARCXML_FILE
+HELP
+    exit;
+}