[librecat-dev] string operations, defining functions in Catmandu
captsolo at gmail.com
Wed Jul 12 11:38:26 CEST 2017
On 4 July 2017 at 16:48, Patrick Hochstenbach <Patrick.Hochstenbach at ugent.be
> In Catmandu::MARC 1.16 you’ll have the `marc_copy` and `marc_paste` fix
> # Copy the content of the 100 field to a temporary variable
Thanks a lot - it really helps! :)
# Change the tag of the first (and only probably) copied field to ‘400'
Note: this command sets the tag value to a numeric 400 rather than '400' -
but that does not prevent from exporting correct data to MARC.
> > On 3 Jul 2017, at 18:49, Uldis Bojars <captsolo at gmail.com> wrote:
> > On 1 July 2017 at 13:58, Patrick Hochstenbach <
> Patrick.Hochstenbach at ugent.be> wrote:
> > >> 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
> > # Copy the 100 field to 400
> > do list(path:record, var:c)
> > if all_match(c.0,100)
> > copy_field(c,copy.$append)
> > replace_all(copy.$end.0,100,400)
> > end
> > end
> > move_field(copy.*,record.$append)
> > remove_field(copy)
> > This does not quite work - the 100 field gets duplicated (added to the
> end of the record) but its type is never changed from 100 to 400.
> > Any idea how to fix it? - I realise that everything that is necessary
> can be done using ARRAY operations but I don't yet know how to correctly
> write them.
> > Also: how would you read the value of the 1st indicator of a certain
> MARC field?
> > - [in this case] it is OK to assume that the field appears in the
> record just once
> > Thanks,
> > Uldis
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the librecat-dev