[Koha-cvs] koha/misc/migration_tools bulkmarcimport.pl [rel_3_0]
paul poulain
paul at koha-fr.org
Wed Dec 6 18:35:38 CET 2006
CVSROOT: /sources/koha
Module name: koha
Branch: rel_3_0
Changes by: paul poulain <tipaul> 06/12/06 17:35:38
Modified files:
misc/migration_tools: bulkmarcimport.pl
Log message:
- minor bugfix for using marcflavour systempref
- minor improvement for showing import status
- commenting the zebra related lines : the speed when bulkmarcimporting with zebra is really awful. So, the best is to comment it in biblio.pm. In this case, there is no need to commit zebra changes !
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/bulkmarcimport.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.7.2.3&r2=1.7.2.4
Patches:
Index: bulkmarcimport.pl
===================================================================
RCS file: /sources/koha/koha/misc/migration_tools/bulkmarcimport.pl,v
retrieving revision 1.7.2.3
retrieving revision 1.7.2.4
diff -u -b -r1.7.2.3 -r1.7.2.4
--- bulkmarcimport.pl 5 Dec 2006 11:35:31 -0000 1.7.2.3
+++ bulkmarcimport.pl 6 Dec 2006 17:35:38 -0000 1.7.2.4
@@ -21,7 +21,7 @@
#
# Problems remain if there are MARC 21 records where 000/09 is set incorrectly.
# -- thd.
-MARC::Charset->ignore_errors(1);
+# MARC::Charset->ignore_errors(1);
use C4::Context;
use C4::Biblio;
@@ -34,6 +34,8 @@
my ( $input_marc_file, $number) = ('',0);
my ($version, $delete, $test_parameter,$char_encoding, $verbose, $commit);
+$|=1;
+
GetOptions(
'commit:f' => \$commit,
'file:s' => \$input_marc_file,
@@ -188,8 +190,10 @@
print "TESTING MODE ONLY\n DOING NOTHING\n===============\n";
}
-$marcFlavour = 'MARC21' unless ($marcFlavour);
+my $marcFlavour = C4::Context->preference('marcflavour') || 'MARC21';
+
print "Characteristic MARC flavour: $marcFlavour\n" if $verbose;
+# die;
my $starttime = gettimeofday;
my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
$batch->warnings_off();
@@ -207,23 +211,25 @@
my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.itemnumber",'');
# $dbh->do("lock tables biblio write, biblioitems write, items write, marc_biblio write, marc_subfield_table write, marc_blob_subfield write, marc_word write, marc_subfield_structure write, stopwords write");
while ( my $record = $batch->next() ) {
-warn "I:".$i;
-warn "NUM:".$number;
+# warn "=>".$record->as_formatted;
+# warn "I:".$i;
+# warn "NUM:".$number;
$i++;
-
- if ($i==$number) {
- z3950_extended_services('commit',set_service_options('commit'));
- print "COMMIT OPERATION SUCCESSFUL\n";
-
- my $timeneeded = gettimeofday - $starttime;
- die "$i MARC records imported in $timeneeded seconds\n";
- }
- # perform the commit operation ever so often
- if ($i==$commit) {
- z3950_extended_services('commit',set_service_options('commit'));
- $commit+=$commitnum;
- print "COMMIT OPERATION SUCCESSFUL\n";
- }
+ print ".";
+ print "\r$i" unless $i % 100;
+# if ($i==$number) {
+# z3950_extended_services('commit',set_service_options('commit'));
+# print "COMMIT OPERATION SUCCESSFUL\n";
+#
+# my $timeneeded = gettimeofday - $starttime;
+# die "$i MARC records imported in $timeneeded seconds\n";
+# }
+# # perform the commit operation ever so often
+# if ($i==$commit) {
+# z3950_extended_services('commit',set_service_options('commit'));
+# $commit+=$commitnum;
+# print "COMMIT OPERATION SUCCESSFUL\n";
+# }
#now, parse the record, extract the item fields, and store them in somewhere else.
## create an empty record object to populate
@@ -281,10 +287,11 @@
print "$i : $nbitems items found\n" if $verbose;
# now, create biblio and items with Addbiblio call.
unless ($test_parameter) {
+ warn "NEWREC : ".$newRecord->as_formatted;
my ($bibid,$oldbibitemnum) = AddBiblio($newRecord,'');
warn "ADDED biblio NB $bibid in DB\n" if $verbose;
for (my $i=0;$i<=$#items;$i++) {
- warn "here is the biblioitemnumber $oldbibitemnum";
+# warn "here is the biblioitemnumber $oldbibitemnum";
AddItem($items[$i],$bibid,$oldbibitemnum);
}
}
More information about the Koha-cvs
mailing list