[Koha-cvs] koha/misc importintotobiblioitems.pl [dev_week]

Tumer Garip tgarip at neu.edu.tr
Sat Jul 8 01:07:13 CEST 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		dev_week
Changes by:	Tumer Garip <tgarip1957>	06/07/07 23:07:13

Added files:
	misc           : importintotobiblioitems.pl 

Log message:
	Small script to import MARCrecords into biblioitems. Useful when upgrading. Assumes 090$c for biblionumber

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/misc/importintotobiblioitems.pl?cvsroot=koha&only_with_tag=dev_week&rev=1.1.2.1

Patches:
Index: importintotobiblioitems.pl
===================================================================
RCS file: importintotobiblioitems.pl
diff -N importintotobiblioitems.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ importintotobiblioitems.pl	7 Jul 2006 23:07:13 -0000	1.1.2.1
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+# script that correct the marcxml  from in biblioitems 
+#  Written by TG on 10/04/2006
+use strict;
+
+# Koha modules used
+
+use C4::Context;
+use C4::Biblio;
+use MARC::Record;
+use MARC::File::USMARC;
+use MARC::File::XML;
+use MARC::Batch;
+use Time::HiRes qw(gettimeofday);
+use Getopt::Long;
+my ( $input_marc_file);
+
+GetOptions(
+    'file:s'    => \$input_marc_file, 
+);
+
+if ($input_marc_file eq '') {
+	print <<EOF
+small script to import an iso2709 file into Koha biblioitems Useful when upgrading.
+Warning assumes hardcode 090$c for  biblionumber
+parameters :
+
+\tfile /path/to/file/to/import : the file to import
+
+
+SAMPLE : ./importintobiblioitems.pl -file /home/neu/koha.dev/local/iso2709.mrc
+EOF
+;#'
+die;
+}
+my $starttime = gettimeofday;
+my $timeneeded;
+my $dbh = C4::Context->dbh;
+
+my $sth2=$dbh->prepare("update biblioitems  set marc=? where biblionumber=?");
+my $i=0;
+
+my $batch = MARC::Batch->new( 'USMARC', $input_marc_file );
+$batch->warnings_off();
+$batch->strict_off();
+my $i=0;
+while ( my $record = $batch->next() ) {
+### WARNING biblionumber is harcoded for 090$c
+my $biblionumber=$record->field('090')->subfield('c');
+$i++;
+$sth2->execute($record->as_usmarc,$biblionumber) if $biblionumber;
+print "$biblionumber \n";
+}
+
+$timeneeded = gettimeofday - $starttime ;
+	print "$i records in $timeneeded s\n" ;
+
+END;





More information about the Koha-cvs mailing list