[librecat-dev] string operations, defining functions in Catmandu

Uldis Bojars captsolo at gmail.com
Thu Jul 13 12:26:00 CEST 2017


On 4 July 2017 at 16:48, Patrick Hochstenbach <Patrick.Hochstenbach at ugent.be
> wrote:

> Carsten Klee and I have been working on two new Fixes the last 2 days that
> could make copying and pasting MARC fields a bit easier than processing raw
> data.
> In Catmandu::MARC 1.16 you’ll have the `marc_copy` and `marc_paste` fix
> available:
>

Can `marc_copy` and `marc_paste` help simplify this task? :

1) form new MARC fields ("400") that consist of some subfields (in this
order: $a $q $b $c $d) of an existing field ("100") ...

2) ... with "." added to the last subfield that exists (e.g. if $d exists
append "." to it unless it already ends with ".", otherwise do the same
with $c, [...]).

3) preserve the indicators of the original "100" field.

It is not a straightforward match of `marc_copy` because of the
requirements (1) and (2).

I currently solve it as Patrick suggested before `marc_copy` was
introduced but this solution does not preserve indicators:

marc_map("100a", "f100a")
marc_map("100q", "f100q")
marc_map("100b", "f100b")
marc_map("100c", "f100c")
marc_map("100d", "f100d")

if marc_match(100aqbcd,"\.$")
  set_field(do_nothing, 'true')
end

marc_add(400
            ,a ,$.f100a
            ,q ,$.f100q
            ,b ,$.f100b
            ,c ,$.f100c
            ,d ,$.f100d)

if exists(do_nothing)
    nothing()
else
    append(record.$last.$last,".")
end

---

The new fixes (copy/paste) will be useful for making copies of this "400"
field (we may need multiple "400" fields each with additional subfields
added) but the issue with not preserving indicators remains.

Uldis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20170713/a65bf61a/attachment.html>


More information about the librecat-dev mailing list