<div dir="ltr"><div>Hi Patrick,</div><div><br></div><div>Thanks!</div><div><br></div><div>Is this file lookup approach viable in case if the lookup table is large (40+ thousand entries)?</div><div><br></div><div>I noticed that Catmandu can work with MongoDB or other databases and was wondering if they might be useful here. Unfortunately, I don't have experience using Catmandu with these databases.</div><div><br></div><div>Cheers,</div><div>Uldis</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 7 Jan 2020 at 17:32, Patrick Hochstenbach <<a href="mailto:Patrick.Hochstenbach@ugent.be">Patrick.Hochstenbach@ugent.be</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">First create a file lookup.csv:<br>
<br>
name,value<br>
foo,bar<br>
bla,blo<br>
test,rest<br>
<br>
Now you can process your marc with this fix:<br>
<br>
do marc_each()<br>
  if marc_has(372a)<br>
    marc_map(372a,tmp)<br>
    lookup(tmp,”lookup.csv",delete:1)<br>
    if exists(tmp)<br>
        marc_set(3720,$.tmp)<br>
    end<br>
  end<br>
end<br>
<br>
The ‘do marc_each’ will make sure this fix is executed for each seperate field  in the marc (and supports repeated fields). This fix will not work when you want to set the value of another MARC fields at a different place in the MARC record.<br>
<br>
Patrick<br>
<br>
> On 7 Jan 2020, at 13:48, Uldis Bojars <<a href="mailto:captsolo@gmail.com" target="_blank">captsolo@gmail.com</a>> wrote:<br>
> <br>
> Hi all,<br>
> <br>
> How can I use Catmandu to look up values in a MARC subfield (e.g. 372 $a) in a database and add information found in the database to this MARC field (in subfield $0 in this case)?<br>
> <br>
> The list of values to look up comes from the a MARC authority file: system numbers (fld. 001) and labels (fld. 150 $a) of MARC 150 records.<br>
> <br>
> It makes sense to preprocess the MARC file and extract the fields to look up (system number, label) but what is the best practice for storing and looking up this information using Catmandu?<br>
> <br>
> Best regards,<br>
> Uldis<br>
> <br>
> _______________________________________________<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-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.de/mailman2/cgi/unibi/listinfo/librecat-dev</a><br>
> - project website: <a href="http://librecat.org/" rel="noreferrer" target="_blank">http://librecat.org/</a><br>
<br>
</blockquote></div></div>