[librecat-dev] Camandu, data lookup

Patrick Hochstenbach Patrick.Hochstenbach at UGent.be
Tue Jan 7 16:49:28 CET 2020


It works also for databases. The database should be filled with records where the `_id` field contains the name you want to lookup and all the other fields in the record are whatever you like.

E.g.:

_id: foo
value: bar
more: data

_id: bar
value: blo
more: data
and:
   - nested 
   - too

_id: test
value: rest

The fix will then be:

> do marc_each()
>   if marc_has(372a)
>     marc_map(372a,tmp)
>     lookup_in_store(tmp,MongoDB,database_name:mycoolddata,delete:1)
>     if exists(tmp)
>         marc_set(3720,$.tmp.value)
>     end
>   end
> end

Patrick


> On 7 Jan 2020, at 16:43, Uldis Bojars <captsolo at gmail.com> wrote:
> 
> Hi Patrick,
> 
> Thanks!
> 
> Is this file lookup approach viable in case if the lookup table is large (40+ thousand entries)?
> 
> 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.
> 
> Cheers,
> Uldis
> 
> 
> On Tue, 7 Jan 2020 at 17:32, Patrick Hochstenbach <Patrick.Hochstenbach at ugent.be> wrote:
> First create a file lookup.csv:
> 
> name,value
> foo,bar
> bla,blo
> test,rest
> 
> Now you can process your marc with this fix:
> 
> do marc_each()
>   if marc_has(372a)
>     marc_map(372a,tmp)
>     lookup(tmp,”lookup.csv",delete:1)
>     if exists(tmp)
>         marc_set(3720,$.tmp)
>     end
>   end
> end
> 
> 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.
> 
> Patrick
> 
> > On 7 Jan 2020, at 13:48, Uldis Bojars <captsolo at gmail.com> wrote:
> > 
> > Hi all,
> > 
> > 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)?
> > 
> > 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.
> > 
> > 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?
> > 
> > Best regards,
> > Uldis
> > 
> > _______________________________________________
> > librecat-dev mailing list
> > - send list mails to 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/
> 




More information about the librecat-dev mailing list