X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=misc%2Fmigration_tools%2Fbulkmarcimport.pl;h=28753b315cf6b6915c9d2a0e3c69c7633b240b8c;hb=84805701972fc6d580e40105f755613b4136b981;hp=7bb6be64ad2d1e50767f95f645cd400a1daae821;hpb=daf2ebc4f5aeaf3a73e11915a17a2a81eafc5cb9;p=koha.git diff --git a/misc/migration_tools/bulkmarcimport.pl b/misc/migration_tools/bulkmarcimport.pl index 7bb6be64ad..28753b315c 100755 --- a/misc/migration_tools/bulkmarcimport.pl +++ b/misc/migration_tools/bulkmarcimport.pl @@ -31,11 +31,16 @@ use Getopt::Long; use IO::File; use Pod::Usage; +my $localcust= $FindBin::Bin.'/LocalChanges.pm'; +$localcust= -e $localcust? $localcust: undef; +require $localcust if $localcust; +$localcust=\&customize if $localcust; + use open qw( :std :encoding(UTF-8) ); binmode( STDOUT, ":encoding(UTF-8)" ); my ( $input_marc_file, $number, $offset) = ('',0,0); my ($version, $delete, $test_parameter, $skip_marc8_conversion, $char_encoding, $verbose, $commit, $fk_off,$format,$biblios,$authorities,$keepids,$match, $isbn_check, $logfile); -my ( $insert, $filters, $update, $all, $yamlfile, $authtypes ); +my ( $insert, $filters, $update, $all, $yamlfile, $authtypes, $append ); my $cleanisbn = 1; my ($sourcetag,$sourcesubfield,$idmapfl, $dedup_barcode); my $framework = ''; @@ -52,10 +57,11 @@ GetOptions( 't|test' => \$test_parameter, 's' => \$skip_marc8_conversion, 'c:s' => \$char_encoding, - 'v:s' => \$verbose, + 'v:i' => \$verbose, 'fk' => \$fk_off, 'm:s' => \$format, 'l:s' => \$logfile, + 'append' => \$append, 'k|keepids:s' => \$keepids, 'b|biblios' => \$biblios, 'a|authorities' => \$authorities, @@ -76,6 +82,7 @@ GetOptions( ); $biblios ||= !$authorities; $insert ||= !$update; +my $writemode = ($append) ? "a" : "w"; if ($all) { $insert = 1; @@ -182,7 +189,7 @@ my $sth_isbn = $dbh->prepare("SELECT biblionumber,biblioitemnumber FROM biblioit $dbh->{AutoCommit} = 0; my $loghandle; if ($logfile){ - $loghandle= IO::File->new($logfile,"w") ; + $loghandle= IO::File->new($logfile, $writemode) ; print $loghandle "id;operation;status\n"; } RECORD: while ( ) { @@ -202,9 +209,10 @@ RECORD: while ( ) { # skip if we get an empty record (that is MARC valid, but will result in AddBiblio failure last unless ( $record ); $i++; - print "."; - print "\n$i" unless $i % 100; - + if( ($verbose//1)==1 ) { #no dot for verbose==2 + print "." . ( $i % 100==0 ? "\n$i" : '' ); + } + # transcode the record to UTF8 if needed & applicable. if ($record->encoding() eq 'MARC-8' and not $skip_marc8_conversion) { # FIXME update condition @@ -216,6 +224,7 @@ RECORD: while ( ) { } } SetUTF8Flag($record); + &$localcust($record) if $localcust; my $isbn; # remove trailing - in isbn (only for biblios, of course) if ($biblios && $cleanisbn) { @@ -459,6 +468,7 @@ RECORD: while ( ) { } $dbh->commit() if (0 == $i % $commitnum); } + print $record->as_formatted()."\n" if ($verbose//0)==2; last if $i == $number; } $dbh->commit(); @@ -632,6 +642,10 @@ The I of records to wait before performing a 'commit' operation File logs actions done for each record and their status into file +=item B<-append> + +If specified, data will be appended to the logfile. If not, the logfile will be erased for each execution. + =item B<-t, -test> Test mode: parses the file, saying what he would do, but doing nothing.