[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/misc bulkmarcimport.pl,1.3,1.4
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/misc bulkmarcimport.pl,1.3,1.4 |
Date: |
Mon, 08 Sep 2003 01:41:20 -0700 |
Update of /cvsroot/koha/koha/misc
In directory sc8-pr-cvs1:/tmp/cvs-serv31709/misc
Modified Files:
bulkmarcimport.pl
Log Message:
some perf improvment tries
Index: bulkmarcimport.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/bulkmarcimport.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** bulkmarcimport.pl 7 Jul 2003 14:49:41 -0000 1.3
--- bulkmarcimport.pl 8 Sep 2003 08:41:18 -0000 1.4
***************
*** 10,24 ****
use C4::Context;
use C4::Biblio;
use Getopt::Long;
my ( $input_marc_file, $number) = ('',0);
! my ($version, $delete, $test_parameter,$char_encoding);
GetOptions(
'file:s' => \$input_marc_file,
'n' => \$number,
! 'v' => \$version,
'd' => \$delete,
't' => \$test_parameter,
'c:s' => \$char_encoding,
);
--- 10,26 ----
use C4::Context;
use C4::Biblio;
+ use Time::HiRes qw(gettimeofday);
use Getopt::Long;
my ( $input_marc_file, $number) = ('',0);
! my ($version, $delete, $test_parameter,$char_encoding, $verbose);
GetOptions(
'file:s' => \$input_marc_file,
'n' => \$number,
! 'h' => \$version,
'd' => \$delete,
't' => \$test_parameter,
'c:s' => \$char_encoding,
+ 'v:s' => \$verbose,
);
***************
*** 27,32 ****
small script to import an iso2709 file into Koha.
parameters :
! \tv : this version/help screen
\tfile /path/to/file/to/dump : the file to dump
\tn : the number of the record to import. If missing, all the file is imported
\tt : test mode : parses the file, saying what he would do, but doing nothing.
--- 29,35 ----
small script to import an iso2709 file into Koha.
parameters :
! \th : this version/help screen
\tfile /path/to/file/to/dump : the file to dump
+ \tv : verbose mode. 1 means "some infos", 2 means "MARC dumping"
\tn : the number of the record to import. If missing, all the file is imported
\tt : test mode : parses the file, saying what he would do, but doing nothing.
***************
*** 64,68 ****
}
$char_encoding = 'USMARC' unless ($char_encoding);
! print "CHAR : $char_encoding\n";
my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
$batch->warnings_off();
--- 67,72 ----
}
$char_encoding = 'USMARC' unless ($char_encoding);
! print "CHAR : $char_encoding\n" if $verbose;
! my $starttime = gettimeofday;
my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
$batch->warnings_off();
***************
*** 71,84 ****
#1st of all, find item MARC tag.
my ($tagfield,$tagsubfield) =
&MARCfind_marc_from_kohafield($dbh,"items.itemnumber");
!
while ( my $record = $batch->next() ) {
$i++;
#now, parse the record, extract the item fields, and store them in
somewhere else.
$record =
MARC::File::USMARC::decode(char_decode($record->as_usmarc(),$char_encoding));
! warn "==>".$record->as_formatted();
my @fields = $record->field($tagfield);
- print "biblio $i";
my @items;
! my $nbitems;
foreach my $field (@fields) {
--- 75,87 ----
#1st of all, find item MARC tag.
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() ) {
$i++;
#now, parse the record, extract the item fields, and store them in
somewhere else.
$record =
MARC::File::USMARC::decode(char_decode($record->as_usmarc(),$char_encoding));
! warn "$i ==>".$record->as_formatted() if $verbose eq 2;
my @fields = $record->field($tagfield);
my @items;
! my $nbitems=0;
foreach my $field (@fields) {
***************
*** 89,97 ****
$nbitems++;
}
! print " : $nbitems items found\n";
# now, create biblio and items with NEWnewXX call.
unless ($test_parameter) {
my ($bibid,$oldbibnum,$oldbibitemnum) =
NEWnewbiblio($dbh,$record);
! warn "ADDED biblio NB $bibid in DB\n";
for (my $i=0;$i<=$#items;$i++) {
NEWnewitem($dbh,$items[$i],$bibid);
--- 92,100 ----
$nbitems++;
}
! print "$i : $nbitems items found\n" if $verbose;
# now, create biblio and items with NEWnewXX call.
unless ($test_parameter) {
my ($bibid,$oldbibnum,$oldbibitemnum) =
NEWnewbiblio($dbh,$record);
! warn "ADDED biblio NB $bibid in DB\n" if $verbose;
for (my $i=0;$i<=$#items;$i++) {
NEWnewitem($dbh,$items[$i],$bibid);
***************
*** 99,100 ****
--- 102,106 ----
}
}
+ # $dbh->do("unlock tables");
+ my $timeneeded = gettimeofday - $starttime;
+ print "$i MARC record done in $timeneeded seconds";
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/misc bulkmarcimport.pl,1.3,1.4,
Paul POULAIN <=