<div dir="ltr"><div class="gmail_extra"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>This is very helpful, Patrick. Thanks much.</div></div></div></div></div></div>
<br><div class="gmail_quote">On Mon, Oct 3, 2016 at 1:53 AM, Patrick Hochstenbach <span dir="ltr"><<a href="mailto:Patrick.Hochstenbach@ugent.be" target="_blank">Patrick.Hochstenbach@ugent.be</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Yes.<br>
<br>
A MARC record in Catmandu is just a ‘record’ key containing an array of arrays (one array for each MARC field). To make it easier to manipulate this array-of-arrays Catmandu marc_map, marc_add, marc_set etc fixes were created.<br>
<br>
There is a Bind marc_each() that loops over a MARC record (it loops over all the fields). You use this most often in combination with a marc_match condition:<br>
<br>
do marc_each()<br>
   # If the current field is 100 and matches some regex<br>
   if marc_match(“100”,”.*”)<br>
       marc_map(100a,myfield)<br>
       lookup(myfield,’list.csv’)<br>
       marc_set(100a,$.myfield)<br>
   end<br>
end<br>
<br>
The marc_each is only required when you do no-trivial things on repeated fields. The 100 field is usually not a repeated field so the Fix below would do exactly the same (and much faster):<br>
<br>
marc_map(100a,myfield)<br>
lookup(myfield,’list.csv’)<br>
marc_set(100a,$.myfield)<br>
<br>
The marc_add field adds new (sub)fields to the record. E.g. add a 101a to the MARC<br>
<br>
marc_add(‘100', a, 'test’ )<br>
<br>
<br>
or an 100a with indicators set:<br>
<br>
marc_add(‘100', ‘ind1', 1 , ‘ind2', 4, ‘a', 'test’ )<br>
<br>
Indicators are not required..in Catmandu that is..maybe they are in MARC for some fields but that is another topic<br>
<br>
Patrick<br>
<br>
> On 02 Oct 2016, at 23:34, Jason Loeffler <<a href="mailto:j@minorscience.com">j@minorscience.com</a>> wrote:<br>
><br>
> I've worked through CSV to JSON and JSON to JSON converters using binds in order to operate on an object-value pair using the contents of an external text file/dictionary.<br>
><br>
> E.g.<br>
><br>
> # linked_agents.ref<br>
> do list(path => linked_agents)<br>
>   add_field("foor","bar")<br>
>   replace_all("ref","[^a-zA-z0-<wbr>9\s]","");<br>
>   lookup("ref","list.csv");<br>
> end<br>
><br>
> This works very well. But is there a way to execute a similar task with a MARC to MARC conversion?<br>
><br>
> Something like firing a lookup in the marc_each context?<br>
><br>
> do marc_each()<br>
>     lookup('some datafield', 'list.csv')<br>
> end<br>
><br>
> Jason Loeffler<br>
> Technology Consultant | The American Academy in Rome<br>
><br>
> ______________________________<wbr>_________________<br>
> librecat-dev mailing list<br>
> - send list mails to <a href="mailto:librecat-dev@lists.uni-bielefeld.de">librecat-dev@lists.uni-<wbr>bielefeld.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.<wbr>de/mailman2/cgi/unibi/<wbr>listinfo/librecat-dev</a><br>
> - project website: <a href="http://librecat.org/" rel="noreferrer" target="_blank">http://librecat.org/</a><br>
<br>
Patrick Hochstenbach - digital architect<br>
University Library Ghent<br>
Sint-Hubertusstraat 8 - 9000 Ghent - Belgium<br>
<a href="mailto:patrick.hochstenbach@ugent.be">patrick.hochstenbach@ugent.be</a><br>
<a href="tel:%2B32%20%280%299%20264%207980" value="+3292647980">+32 (0)9 264 7980</a><br>
<br>
</blockquote></div><br></div></div>