[librecat-dev] Adding MARC subfields using Catmandu

Patrick Hochstenbach Patrick.Hochstenbach at UGent.be
Fri May 19 16:28:40 CEST 2017


Hi Basil,

There is an inelegant way to do this:

do marc_each()
    if marc_match("245a","Cross-platform Perl")
       add_field(record.0.$append,"h")
       add_field(record.0.$append,"blablabla")
    end
end

But indeed this should be an option that Catmandu::MARC would need.
The main usage for Catmandu::MARC was always to map data to other
formats, not the cleaning of MARC records. I'll open an issue for this

https://github.com/LibreCat/Catmandu-MARC/issues/68

Patrick
________________________________________
From: librecat-dev-bounces at lists.uni-bielefeld.de <librecat-dev-bounces at lists.uni-bielefeld.de> on behalf of Basil Marti <basil.marti at unibas.ch>
Sent: Friday, May 19, 2017 4:11 PM
To: librecat-dev at lists.uni-bielefeld.de
Subject: [librecat-dev] Adding MARC subfields using Catmandu

Dear all

Is there an elegant way (either using the Catmandu fix-language or using Catmandu inside a Perl script) to add subfields to an existing MARC field, without replacing existing subfields?

E.g. if some condition is true, add subfield $h with content "Microfilm" to field 245.

I could use marc_set('245h','Microfilm'), but if I understand its behavior correctly, it will replace any existing subfield $h.

The only way I found is reading out all existing 245 subfields, deleting the field and and then creating a new 245 field with both the original subfields and the new subfield:

marc_map('245a','title');
marc_map('245b','subtitle');
marc_map('245c','author');
marc_map('245h','medium');
if "some condition"
     marc_remove ('245')
     marc_add('245', 'a', '$.title', 'b', '$.subtitle', 'c', '$.author', 'h', '$.medium', 'h', 'Microfilm')
end

Especially if a field has a lot of different subfields and/or repeatable subfields this is rather complicated. Is there any easier way?

Best regards

Basil

Basil Marti | Systembibliothekar
Universität Basel | Universitätsbibliothek | IT-Abteilung
Schönbeinstrasse 18-20 | 4056 Basel | Schweiz
Tel +41 61 207 11 88 | Fax +41 61 207 31 03
E-Mail basil.marti at unibas.ch | http://www.ub.unibas.ch


_______________________________________________
librecat-dev mailing list
- send list mails to librecat-dev at lists.uni-bielefeld.de
- to unsubscribe or change options, visit https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev
- project website: http://librecat.org/



More information about the librecat-dev mailing list