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

Patrick Hochstenbach Patrick.Hochstenbach at UGent.be
Sat Jul 1 12:58:32 CEST 2017

>> 1) Is it possible to also "copy" indicator values (from 100 field)? How would you do this?
>> 2) Is it possible to make a copy of a MARC field (within the record)?

With Fix you can do anything you want with JSON. A MARC record is just a 'record' key in a JSON document which contains an ARRAY of ARRAY values. All the fixes copy_field, move_field, etc etc can operate on each type of JSON document. A copy of a MARC field could be implemented with something like:

# Copy the 100 field to 400
do list(path:record, var:c)
  if all_match(c.0,100)


This is ARRAY processing without knowing this ARRAY is MARC. What Catmandu::MARC does is hiding a lot of this array processing and provide a much simpler MARCPath and MARCSpec syntax. Alas, the marc_copy_field is not something implemented yet in this easier syntax, but I've made a ticket for that: https://github.com/LibreCat/Catmandu-MARC/issues/76

?3) marc_add

The marc_add could be used to add data to a new MARC record ..but I see this option doesn't work anymore. Also for this I created a ticket: https://github.com/LibreCat/Catmandu-MARC/issues/77

> On 28 Jun 2017, at 18:41, Uldis Bojars <captsolo at gmail.com<mailto:captsolo at gmail.com>> wrote:
> Hi,
> Could you suggest how to do this in Catmandu:
> I need to form a new MARC field ("400") that consist of some subfields (in this order: $a $q $b $c $d) of an existing field ("100"). That much is not difficult, but there's another condition:
> "." must be 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, [...]) .
> Questions:
> 1) how to determine if a field (e.g. fld_100d created via marc_map) ends with "." ?
> 2) is there a way to "package" some functionality and call it when needed?
> In this case it would be good to create a function that appends "." to the field provided as a parameter unless it already ends with ".".
> Then what is needed could be achieved like this:
> if exists("fld_100d"):
>    my_function("fld_100d")
> elsif exists("fld_100c"):
>    my_function("fld_100c")
> elsif [...]
>    [...]
> end
> P.S. Perhaps there is a more idiomatic way how to do this in Catmandu?
> Thanks,
> Uldis
> _______________________________________________
> librecat-dev mailing list
> - send list mails to librecat-dev at lists.uni-bielefeld.de<mailto: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/

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

More information about the librecat-dev mailing list