<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
But while waiting for this new feature you can use a dirty trick to get the required result. The Fix script below will add the 100 subfields to the 400 field and adds a<br>
period “.” when required:<br>
<br>
$ cat marc.fix<br>
marc_map(100a,f100a)<br>
marc_map(100q,f100q)<br>
marc_map(100b,f100b)<br>
marc_map(100c,f100c)<br>
marc_map(100d,f100d)<br>
<br>
if marc_match(100aqbcd,"\.$")<br>
    # Do nothing<br>
    marc_add(400<br>
        ,a ,$.f100a<br>
        ,q ,$.f100q<br>
        ,b ,$.f100b<br>
        ,c ,$.f100c<br>
        ,d ,$.f100d)<br></blockquote><div><br></div><div>1) Is it possible to also "copy" indicator values (from 100 field)? How would you do this?</div><div><br></div><div>I think Catmandu docs mentioned that you can not read indicator values with marc_map(). </div><div>In that case knowing what the values are might be helpful: ind1 = (0, 1 or 3), ind3 = " ".</div><div><br></div><div>2) Is it possible to make a copy of a MARC field (within the record)?</div><div><br></div><div>E.g. copy the newly created 400 field to another field.</div><div><br></div><div>Another way to solve this would be if there were functions that can (a) dump the "raw" structure of MARC field into a separate field and (b) put it back as a new MARC field.</div><div><br></div><div>If I understand it correctly, there is a function for copying an arbitrary JSON field (<span style="color:rgb(36,41,46);font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;background-color:rgb(246,248,250)">copy_field</span>), but the challenge is finding the right JSON path to identify the necessary MARC field. This part could be solved if marc_map() had a "raw" mode that copies the raw JSON structure instead of converting it to text, although that </div><div><br></div><div>3) In the other response you wrote:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">The main use case was to transform MARC to something else ;). But there is more and more support to change MARC itself.  </blockquote><div><br></div><div>I see ;) - Yet it's great [for cases like this one] that Catmandu can also convert MARC to MARC :) </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">marc_add does have the functionality you can add values to a separate record field:<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">marc_add('900',<br> ind1 , '<br> '<br>,<br> a, 'test'<br>,<br>'b',<br> test , record:record2)<br></blockquote></div><div><br></div><div>Hmm, what does it do?</div><div><br></div><div>I tried it but it did not do anything for me (i.e. it did not create $.record.record2 - just created a regular 900 field inside $.record).</div><div><br></div><div>Thanks a lot,</div><div>Uldis</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<div><div class="gmail-m_-3313603927294503163gmail-m_-6321139617529349181m_6669267379397702592h5">> On 28 Jun 2017, at 18:41, Uldis Bojars <<a href="mailto:captsolo@gmail.com" target="_blank">captsolo@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> Could you suggest how to do this in Catmandu:<br>
><br>
> 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:<br>
><br>
> "." 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, [...]) .<br>
><br>
> Questions:<br>
><br>
> 1) how to determine if a field (e.g. fld_100d created via marc_map) ends with "." ?<br>
><br>
> 2) is there a way to "package" some functionality and call it when needed?<br>
><br>
> 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 ".".<br>
><br>
> Then what is needed could be achieved like this:<br>
><br>
> if exists("fld_100d"):<br>
>    my_function("fld_100d")<br>
> elsif exists("fld_100c"):<br>
>    my_function("fld_100c")<br>
> elsif [...]<br>
>    [...]<br>
> end<br>
><br>
> P.S. Perhaps there is a more idiomatic way how to do this in Catmandu?<br>
><br>
> Thanks,<br>
> Uldis<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> librecat-dev mailing list<br>
> - send list mails to <a href="mailto:librecat-dev@lists.uni-bielefeld.de" target="_blank">librecat-dev@lists.uni-bielefe<wbr>ld.de</a><br>
> - to unsubscribe or change options, visit <a href="https://lists.uni-bielefeld.de/mailman2/cgi/unibi/listinfo/librecat-dev" rel="noreferrer" target="_blank">https://lists.uni-bielefeld.de<wbr>/mailman2/cgi/unibi/listinfo/l<wbr>ibrecat-dev</a><br>
> - project website: <a href="http://librecat.org/" rel="noreferrer" target="_blank">http://librecat.org/</a><br>
<br>
</blockquote></div></div></div>