No subject


Thu Nov 17 10:48:57 UTC 2005


>From chris at katipo.co.nz Thu May  5 04:34:32 2005
Return-Path: <chris at katipo.co.nz>
Delivered-To: chris at wilbur.katipo.co.nz
Received: (qmail 4856 invoked from network); 4 May 2005 16:34:32 -0000
Received: from unknown (HELO shelob.katipo.co.nz) (202.50.109.222)
  by wilbur.katipo.co.nz with SMTP; 4 May 2005 16:34:32 -0000
Received: by shelob.katipo.co.nz (Postfix, from userid 1001)
	id 497A3847AF; Thu,  5 May 2005 04:34:32 +1200 (NZST)
X-Original-To: chris at katipo.co.nz
Delivered-To: chris at katipo.co.nz
Received: from localhost (localhost [127.0.0.1])
	by shelob.katipo.co.nz (Postfix) with ESMTP id B69E0847BF;
	Thu,  5 May 2005 04:34:23 +1200 (NZST)
Received: from shelob.katipo.co.nz ([127.0.0.1])
	by localhost (staff.katipo.co.nz [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 04203-04; Thu, 5 May 2005 04:34:23 +1200 (NZST)
Received: from daddy-mx.katipo.co.nz (daddy.katipo.co.nz [202.50.109.200])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by shelob.katipo.co.nz (Postfix) with ESMTP;
	Thu,  5 May 2005 04:34:23 +1200 (NZST)
Received: from localhost (localhost.katipo.co.nz [127.0.0.1])
	by daddy-mx.katipo.co.nz (Postfix) with ESMTP id DB996E6EEC;
	Thu,  5 May 2005 04:32:03 +1200 (NZST)
Received: from daddy-mx.katipo.co.nz ([127.0.0.1])
	by localhost (daddy.katipo.co.nz [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 17371-05; Thu, 5 May 2005 04:32:02 +1200 (NZST)
Received: from localhost.katipo.co.nz (localhost.katipo.co.nz [127.0.0.1])
	by daddy-mx.katipo.co.nz (Postfix) with ESMTP;
	Thu,  5 May 2005 04:32:02 +1200 (NZST)
Received: from localhost (localhost.katipo.co.nz [127.0.0.1])
	by daddy-mx.katipo.co.nz (Postfix) with ESMTP id 763A5E6E87
	for <koha at lists.katipo.co.nz>; Thu,  5 May 2005 04:31:57 +1200 (NZST)
Received: from daddy-mx.katipo.co.nz ([127.0.0.1])
	by localhost (daddy.katipo.co.nz [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 17371-04 for <koha at lists.katipo.co.nz>;
	Thu, 5 May 2005 04:31:55 +1200 (NZST)
Received: from wlpl.org (mail.wlpl.org [204.95.8.76])
	by daddy-mx.katipo.co.nz (Postfix) with ESMTP
	for <koha at lists.katipo.co.nz>; Thu,  5 May 2005 04:31:55 +1200 (NZST)
Received: from [192.168.1.152] (helo=[192.168.1.152])
	by wlpl.org with esmtp (Exim 2.12 #1) id 1DTMms-0006dm-00
	for koha at lists.katipo.co.nz; Wed, 4 May 2005 11:31:50 -0500
Received: from 127.0.0.1 (AVG SMTP 7.0.308 [266.11.3]);
	Wed, 04 May 2005 11:34:10 -0500
Message-ID: <4278F982.9050204 at wlpl.org>
Date: Wed, 04 May 2005 11:34:10 -0500
From: Tim McMahon - West Liberty Public Library <tmcmahon at wlpl.org>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
X-Accept-Language: en-us, en
MIME-Version: 1.0
To: koha at lists.katipo.co.nz
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at katipo.co.nz
Subject: [Koha] Converting MARC records from Sagebrush Athena
X-BeenThere: koha at lists.katipo.co.nz
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Discussion list for the Koha Library system <koha.lists.katipo.co.nz>
List-Unsubscribe: <http://lists.katipo.co.nz/mailman/listinfo/koha>,
	<mailto:koha-request at lists.katipo.co.nz?subject=unsubscribe>
List-Archive: <http://lists.katipo.co.nz/pipermail/koha>
List-Post: <mailto:koha at lists.katipo.co.nz>
List-Help: <mailto:koha-request at lists.katipo.co.nz?subject=help>
List-Subscribe: <http://lists.katipo.co.nz/mailman/listinfo/koha>,
	<mailto:koha-request at lists.katipo.co.nz?subject=subscribe>
Sender: koha-bounces at lists.katipo.co.nz
Errors-To: koha-bounces at lists.katipo.co.nz
X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at katipo.co.nz
X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at katipo.co.nz
X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16)  on 
	shelob.katipo.co.nz
X-Spam-Level: 
X-Spam-Status: No, hits=-2.6 required=5.0tests=BAYES_00 autolearn=ham 
	version=3.0.2
Status: RO
Content-Length: 2855

I'm looking for comments on my work so far.  Here is the perl script I
wrote to move things to different fields for Koha.  Let me know if you 
see anything that should be changed or could be done a better way.  I'm 
still learning perl, so this could look pretty bad.

First I set up a hash for converting Athena formats to Koha item types. 
  After I read a record, I pick the data I want from the 852 fields.

	852_6 is format
	852_p is barcode
	852_9 is cost
	852_8 is accession date
	852_k is call number prefix
	852_k is call number main
	852_i is call number cutter
	852_m is call number suffix

852_9 is changed to pull any extra characters out of the cost.

Athena allows longer strings for their formats.  852_9 is changed to 
shorter strings using the hash made at the start of the script.

Build a whole call number from the pieces in 852 by putting $k, $h, $i 
and $m together with spaces between and then stripping extra spaces out 
of it.

Put 952 together with our new 852_9, our new call, a code for the home 
branch and holding branch and the barcode.



#!/usr/bin/perl

# use strict;
# use warnings;

## Crate our MARC::Batch object.
use MARC::Batch;
my $infile = $ARGV[0];
my $outfile = $ARGV[1];

my $batch = MARC::Batch->new('USMARC',$infile);

## open a file handle to write to.

open(OUT,">$outfile") or die $!;

my %format = (
	'binder' => BIND,
	'book' => BOOK,
	'book kit' => KIT,
	'books on CD' => BKCD,
	'books on tape' => BKTP,
	'cbook' => BOOK,
	'CD' => CD,
	'CD-ROM' => CD,
	'DVD' => DVD,
	'ebook' => BOOK,
	'equipment' => EQU,
	'file folder' => FILE,
	'frame' => FRAM,
	'hbook' => BOOK,
	'magazine' => MAG,
	'map' => MAP,
	'sbook' => BOOK,
	'tboot' => BOOK,
	'vbook' => BOOK,
	'video' => VID
);

## read each record. modify, then print.
while ( my $record = $batch->next() ) {

## get info from 852 field.
my @fields = $record->field('852');
foreach my $field (@fields) {
$field852_6=$field->subfield('6');
$field852_p=$field->subfield('p');
$field852_9=$field->subfield('9');
$field852_8=$field->subfield('8');
$field852_k=$field->subfield('k');
$field852_h=$field->subfield('h');
$field852_i=$field->subfield('i');
$field852_m=$field->subfield('m');
$field852_9 =~ s/[^0-9.]//ig;

## change the format in 852 6
  my $new_field=$format{$field852_6};
  $field->update( 6 => $new_field );

## Make a new call number for 952 a
$call=$field852_k . ' ' . $field852_h . ' ' . $field852_i . ' ' . 
$field852_m;
while ($call=~s/  / /ig) {}
$call=~s/^ //;
$call=~s/ $//;

## add 952 field from 852 tags
$record->append_fields(
MARC::Field->new('952','','',8=>$field852_8,
	9=>$field852_9,
	a=>$call,
	b=>'WLPL',
	d=>'WLPL',
	p=>$field852_p));

print OUT $record->as_usmarc();
}}
close(OUT);

_______________________________________________
Koha mailing list
Koha at lists.katipo.co.nz
http://lists.katipo.co.nz/mailman/listinfo/koha




More information about the Koha mailing list