From: Shawn Boyette Date: Mon, 9 Feb 2009 16:53:28 +0000 (+0000) Subject: tag reporting in edits is correct again X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=245707b60c8f52fbcc535f879ee7c32b1e233fe5 tag reporting in edits is correct again Working... includes % now --- diff --git a/marc_cleanup b/marc_cleanup index 9afae88..2669fd4 100755 --- a/marc_cleanup +++ b/marc_cleanup @@ -18,7 +18,8 @@ initialize($conf); populate_trash() if ($conf->{trashfile}); # set up files, since everything appears to be in order -open MARC, '<:utf8', (shift || 'incoming.marc.xml') +my $marcfile = shift || 'incoming.marc.xml'; +open MARC, '<:utf8', $marcfile or die "Can't open input file $!\n"; open my $NUMARC, '>:utf8', $conf->{output} or die "Can't open output file $!\n"; @@ -27,6 +28,10 @@ open my $OLD2NEW, '>', 'old2new.map' my $EXMARC = 'EX'; print $NUMARC "\n"; +$conf->{totalrecs} = `grep -c '{totalrecs}; +$conf->{percent} = 0; + my @record = (); # current record storage my %recmeta = (); # metadata about current record my $ptr = 0; # record index pointer @@ -53,12 +58,13 @@ my %commands = ( c => \&print_fullcontext, help => \&help, ); -my @spinner = qw(- / | \\); +my @spinner = qw(- \\ | /); my $sidx = 0; while ( buildrecord() ) { - unless ($conf->{ricount} % 100) { - print "\rWorking... ", $spinner[$sidx]; + unless ($conf->{ricount} % 50) { + $conf->{percent} = int(($conf->{ricount} / $conf->{totalrecs}) * 100); + print "\rWorking (",$conf->{percent},"%) ", $spinner[$sidx]; $sidx = ($sidx == $#spinner) ? 0 : $sidx + 1; } @@ -67,6 +73,10 @@ while ( buildrecord() ) { $ptr = 0; until ($ptr == $#record) { + # get datafield/tag data if we have it + my $rc = stow_record_data(); + return $rc if $rc; + # naked ampersands if ($record[$ptr] =~ /&/ && $record[$ptr] !~ /&\w+?;/) { edit("Naked ampersand"); $ptr= 0; next } @@ -115,10 +125,6 @@ print $OUT "\nDone. \n"; sub do_automated_cleanups { $ptr = 0; until ($ptr == $#record) { - # get datafield/tag data if we have it - my $rc = stow_record_data(); - return $rc if $rc; - # catch empty datafield elements if ($record[$ptr] =~ m/|) {