[Koha] Import query (S P Suresh)

Martin Morris martin at martinmorris.org
Wed Aug 29 19:23:18 NZST 2007


Hello Suresh,

I'm no koha expert, but I would solve your problem by writing a  
little perl script to convert your data into MARC format and then  
import it into your new Koha installation.

I had to do something similar to import data for a library I'm  
migrating to koha, which currently uses a little custom script to  
parse its biblios which are held in a text file, each line something  
like this:

munns donaldw|londonanidoj|p||MUNNS, Donald W|812 -311.2 MUN| 
Londonanidoj|Rickmansworth (GB)|Esperanto Publishing Company|1946| 
98p. 18cm.||K19b Munns 424|

The script I used is very quick and dirty, and looks like this (I can  
send the whole thing if you'd like...):

------
#!/usr/bin/perl -w

use strict;

use MARC::Record;
use Data::Dumper;

open (KOHADATA, "ludkatalogo.txt");
open(OUTPUT, '> katalogo.mrc');
my $c = 0;
my @marcfields;

while ( <KOHADATA> ) {
         $c++;
         print "\n$c\n";
         @marcfields = split(/\|/,$_);
         print $marcfields[5];

         # Create a new record
         my $record = MARC::Record->new();
         $record->encoding( 'UTF-8' );

         # Cataloging Source
         my $catsource = MARC::Field->new(
                 '040','','',
                   a => 'Biblioteko Butler',
                   b => 'epo',
                   c => 'Martin Morris <martin at martinmorris.org>',
                   d => 'Martin Morris <martin at martinmorris.org>'
         );

         # UDC Classification
         my $udc = MARC::Field->new(
                 '080','','',
                   2 => 'Biblioteko Butler',
                   a => $marcfields[5]
         );

         # Geoff King's Classification
         my $gkclass = MARC::Field->new(
                 '084','','',
                   a => $marcfields[12],
                   2 => 'Geoffrey King <ancientbriton at tiscali.co.uk>'
         );

         # Author
         my $author = MARC::Field->new(
                 '100',1,'',
                   a => $marcfields[4]
         );

[.....various other fields imported appropriately]

         $record->append_fields($catsource, $udc, $gkclass, $author,  
$titleinfo, $publicationplace, $physicals, $bibliographic,  
$kohastuff, $koha952);

print OUTPUT $record->as_usmarc();
}
close(OUTPUT);
close(KOHADATA);


Yours would probably need to interrogate your simple table and create  
the array that way, before dumping as MARC records.

Anyway, that may help.  I imagine some of the gurus on here will come  
up with a better idea though!

Martin


On 29 Aug 2007, at 01:00, koha-request at lists.katipo.co.nz wrote:

> Message: 1
> Date: Tue, 28 Aug 2007 19:26:02 +0530
> From: S P Suresh <spsuresh at cmi.ac.in>
> Subject: [Koha] Import query
> To: koha at lists.katipo.co.nz
> Message-ID: <709A1480-F1C5-46BD-BE47-00CD9FB33448 at cmi.ac.in>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Dear all,
>
> Can some developers on the list please help me. We have an existing
> library system maintained currently as a rudimentary mysql table with
> a minimum of fields (barcode, authors, title, publisher, year). How
> best can we import this data into Koha? Does it suffice to write some
> Perl code to load these values into the biblio, items, biblioitems
> tables? Or will it break something? Another idea is to just load the
> relevant fields into the biblio table, without worrying about the
> items and biblioitems tables. (We are planning to manually look into
> each record (searching by author or title) and fill in the biblio
> details with a Z39.50 import, as well as other relevant fields like
> barcode.) Can some of the experts tell me whether this will work
> properly, without breaking  the way Koha works? We want to have our
> old data up and running with Koha.
>
> Thanks in advance for the help. We are experimenting with Koha in our
> library, and it is vital that we start on some rudimentary
> functionality at least. Later when some of us are more familiar with
> its workings, we can realise its full benefits. But it is taking
> time, and we need this help urgently.
>
> If the above approaches are wrong, can someone please tell me what is
> the best approach?
>
> Thanks in advance,
> Suresh



More information about the Koha mailing list