koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/marc updatedb2marc.pl,NONE,1.1 fill_usmarc.pl,1.3,1


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/marc updatedb2marc.pl,NONE,1.1 fill_usmarc.pl,1.3,1.4
Date: Tue, 10 Sep 2002 07:02:46 -0700

Update of /cvsroot/koha/koha/marc
In directory usw-pr-cvs1:/tmp/cvs-serv7003

Modified Files:
        fill_usmarc.pl 
Added Files:
        updatedb2marc.pl 
Log Message:
* fill_usmarc.pl => fills db with MARC21/english data structure. The modifs now 
maps koha item fields to 995 MARC tag.
* updatedb2marc.pl => builds MARC data from old-DB. WARNING : this script 
translate around 30rows/seconds, which is neither good nor bad (if you consider 
that 1 biblio+1 item = more than 50 record in the MARC-DB). But if you plan to 
migrate a 30 000 books db, launch script and go for lunch ;-)


--- NEW FILE ---
#!/usr/bin/perl
# migrate koha-biblios to MARCbiblios

package C4::test;

# Copyright 2000-2002 Katipo Communications
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
# Suite 330, Boston, MA  02111-1307 USA

use strict;
require Exporter;
use C4::Database;
use C4::Catalogue;
use C4::Biblio;
use MARC::Record;
use MARC::File::USMARC;

#die;
my $dbh=&C4Connect;
$dbh->do("delete from marc_biblio");
$dbh->do("delete from marc_blob_subfield");
$dbh->do("delete from marc_subfield_table");
$dbh->do("delete from marc_word");
my $sth=$dbh->prepare("select * from biblio left join biblioitems on 
biblioitems.biblionumber=biblio.biblionumber order by biblio.biblionumber");
my ($row,$row2);
my $sth2 = $dbh->prepare("select count(*) from biblio");
$sth2->execute;
my ($total) = $sth2->fetchrow_array;
my $rest = $total;
$sth->execute;
my $i=0;
while ($row=$sth->fetchrow_hashref) {
    $i++;
    $rest--;
    if ($i>99) {
        $i=0;
        print "$rest / $total\n";
    }
    my $MARCbiblio = 
MARCkoha2marcBiblio($dbh,$row->{biblionumber},$row->{biblioitemnumber});
    &MARCaddbiblio($dbh,$MARCbiblio,$row->{biblionumber});
    my $sth_item = $dbh->prepare("select * from items where biblionumber=? and 
biblioitemnumber=?");
    $sth_item->execute($row->{biblionumber},$row->{biblioitemnumber});
    while ($row2=$sth_item->fetchrow_hashref) {
        my $MARCitem = 
&MARCkoha2marcItem($dbh,$row2->{biblionumber},$row2->{itemnumber});
        &MARCadditem($dbh,$MARCitem,$row2->{biblionumber});
    }
}



Index: fill_usmarc.pl
===================================================================
RCS file: /cvsroot/koha/koha/marc/fill_usmarc.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** fill_usmarc.pl      14 Aug 2002 18:12:53 -0000      1.3
--- fill_usmarc.pl      10 Sep 2002 14:02:42 -0000      1.4
***************
*** 81,91 ****
  $dbh->do("update marc_subfield_structure set kohafield='biblioitems.lccn' 
where tagfield='010' and tagsubfield='a'");
  # items
! $dbh->do("update marc_subfield_structure set kohafield='items.itemnumber' 
where tagfield='890' and tagsubfield='c'");
    #$dbh->do("update marc_subfield_structure set 
kohafield='items.multivolumepart' where tagfield='XXX' and tagsubfield='a'");
! $dbh->do("update marc_subfield_structure set kohafield='items.barcode' where 
tagfield='852' and tagsubfield='p'");
! $dbh->do("update marc_subfield_structure set 
kohafield='items.dateaccessioned' where tagfield='876' and tagsubfield='d'");
! $dbh->do("update marc_subfield_structure set kohafield='items.booksellerid' 
where tagfield='876' and tagsubfield='e'");
! $dbh->do("update marc_subfield_structure set kohafield='items.homebranch' 
where tagfield='876' and tagsubfield='b'");
! $dbh->do("update marc_subfield_structure set 
kohafield='items.replacementprice' where tagfield='876' and tagsubfield='c'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.price' where 
tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set 
kohafield='items.replacementpricedate' where tagfield='XXX' and 
tagsubfield='a'");
--- 81,91 ----
  $dbh->do("update marc_subfield_structure set kohafield='biblioitems.lccn' 
where tagfield='010' and tagsubfield='a'");
  # items
! $dbh->do("update marc_subfield_structure set kohafield='items.itemnumber' 
where tagfield='995' and tagsubfield='s'");
    #$dbh->do("update marc_subfield_structure set 
kohafield='items.multivolumepart' where tagfield='XXX' and tagsubfield='a'");
! $dbh->do("update marc_subfield_structure set kohafield='items.barcode' where 
tagfield='995' and tagsubfield='f'");
! $dbh->do("update marc_subfield_structure set 
kohafield='items.dateaccessioned' where tagfield='995' and tagsubfield='m'");
! #$dbh->do("update marc_subfield_structure set kohafield='items.booksellerid' 
where tagfield='876' and tagsubfield='e'");
! $dbh->do("update marc_subfield_structure set kohafield='items.homebranch' 
where tagfield='995' and tagsubfield='d'");
! #$dbh->do("update marc_subfield_structure set 
kohafield='items.replacementprice' where tagfield='876' and tagsubfield='c'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.price' where 
tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set 
kohafield='items.replacementpricedate' where tagfield='XXX' and 
tagsubfield='a'");
***************
*** 94,100 ****
    #$dbh->do("update marc_subfield_structure set kohafield='items.multivolume' 
where tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.stack' where 
tagfield='XXX' and tagsubfield='a'");
! $dbh->do("update marc_subfield_structure set kohafield='items.notforloan' 
where tagfield='876' and tagsubfield='h'");
! $dbh->do("update marc_subfield_structure set kohafield='items.itemlost' where 
tagfield='876' and tagsubfield='j'");
! $dbh->do("update marc_subfield_structure set kohafield='items.wthdrawn' where 
tagfield='876' and tagsubfield='k'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.bulk' where 
tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.issues' 
where tagfield='XXX' and tagsubfield='a'");
--- 94,100 ----
    #$dbh->do("update marc_subfield_structure set kohafield='items.multivolume' 
where tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.stack' where 
tagfield='XXX' and tagsubfield='a'");
! $dbh->do("update marc_subfield_structure set kohafield='items.notforloan' 
where tagfield='995' and tagsubfield='o'");
! #$dbh->do("update marc_subfield_structure set kohafield='items.itemlost' 
where tagfield='876' and tagsubfield='j'");
! #$dbh->do("update marc_subfield_structure set kohafield='items.wthdrawn' 
where tagfield='876' and tagsubfield='k'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.bulk' where 
tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.issues' 
where tagfield='XXX' and tagsubfield='a'");
***************
*** 103,107 ****
    #$dbh->do("update marc_subfield_structure set kohafield='items.restricted' 
where tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.binding' 
where tagfield='XXX' and tagsubfield='a'");
! $dbh->do("update marc_subfield_structure set kohafield='items.itemnotes' 
where tagfield='876' and tagsubfield='z'");
    #$dbh->do("update marc_subfield_structure set 
kohafield='items.holdingbranch' where tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.interim' 
where tagfield='XXX' and tagsubfield='a'");
--- 103,107 ----
    #$dbh->do("update marc_subfield_structure set kohafield='items.restricted' 
where tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.binding' 
where tagfield='XXX' and tagsubfield='a'");
! $dbh->do("update marc_subfield_structure set kohafield='items.itemnotes' 
where tagfield='995' and tagsubfield='u'");
    #$dbh->do("update marc_subfield_structure set 
kohafield='items.holdingbranch' where tagfield='XXX' and tagsubfield='a'");
    #$dbh->do("update marc_subfield_structure set kohafield='items.interim' 
where tagfield='XXX' and tagsubfield='a'");
***************
*** 9929,9938 ****
      $fields->{'886'}->{'subfields'}->{"2"}->{'name'}="Source of data (NR) 
$a-z - Foreign MARC subfield (R) $0-9 - Foreign MARC subfield (R)";
      $fields->{'886'}->{'subfields'}->{"2"}->{'repeating'}=0;
!     $fields->{'890'}->{'name'}="KOHA item number";
!     $fields->{'890'}->{'repeating'}=1;
!     $fields->{'890'}->{'firstindicator'}="Undefined";
!     $fields->{'890'}->{'secondindicator'}="Undefined";
!     $fields->{'890'}->{'subfields'}->{"c"}->{'name'}="Koha biblio number";
!     $fields->{'890'}->{'subfields'}->{"c"}->{'repeating'}=1;
  ;
  
--- 9929,9949 ----
      $fields->{'886'}->{'subfields'}->{"2"}->{'name'}="Source of data (NR) 
$a-z - Foreign MARC subfield (R) $0-9 - Foreign MARC subfield (R)";
      $fields->{'886'}->{'subfields'}->{"2"}->{'repeating'}=0;
! 
!     $fields->{'995'}->{'name'}="";
!     $fields->{'995'}->{'repeating'}=1;
!     $fields->{'995'}->{'firstindicator'}="Undefined";
!     $fields->{'995'}->{'secondindicator'}="Undefined";
!     $fields->{'995'}->{'subfields'}->{"s"}->{'name'}="Koha item number";
!     $fields->{'995'}->{'subfields'}->{"s"}->{'repeating'}=1;
!     $fields->{'995'}->{'subfields'}->{"f"}->{'name'}="barcode";
!     $fields->{'995'}->{'subfields'}->{"f"}->{'repeating'}=1;
!     $fields->{'995'}->{'subfields'}->{"m"}->{'name'}="dateaccessioned";
!     $fields->{'995'}->{'subfields'}->{"m"}->{'repeating'}=1;
!     $fields->{'995'}->{'subfields'}->{"d"}->{'name'}="homebranch";
!     $fields->{'995'}->{'subfields'}->{"d"}->{'repeating'}=1;
!     $fields->{'995'}->{'subfields'}->{"o"}->{'name'}="notforloan";
!     $fields->{'995'}->{'subfields'}->{"o"}->{'repeating'}=1;
!     $fields->{'995'}->{'subfields'}->{"u"}->{'name'}="item notes";
!     $fields->{'995'}->{'subfields'}->{"u"}->{'repeating'}=1;
  ;
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]