[librecat-dev] bind for appending repeating MARC fields

Jason Loeffler j at minorscience.com
Wed Feb 8 06:48:59 CET 2017


Just following up with my own (potential) solution:

Where list.csv is:

_id,value
1234,"item.1,item.2,item.3"

and the fix is:

# 952
lookup(somefield,list.csv)
split_field(somefield,",")

do list(path:somefield,var:c)
  marc_add('952',ind1,' ',ind2,' ',o,$.c)
end

Seems to do the trick.

Unfortunately, when trying to create a hashmap where the fix is:

catmandu convert CSV to Null --fix 'do
hashmap(exporter:CSV,join:",");nothing();end' < lookup.csv

and the lookup.csv is:

key,value
1234,"item.1"
1234,"item.2"
1234,"item.3"

I get:

Oops! Syntax error in your fixes...

Expected end of input on line 1 at:
do hashmap(exporter:CSV,join:",");nothing();end
^

Opening an issue on Github.

JL


On Tue, Feb 7, 2017 at 5:55 PM, Jason Loeffler <j at minorscience.com> wrote:

> I am trying to figure out how to script a bind that will lookup and
> iterate over an arbitrary list of matches and append successive MARC
> datafields for each match. The basic idea is illustrated below, though I
> presume I need a hashmap to accomplish this? Any ideas?
>
> Source file:
> [
>   {
>     "title": "title1",
>     "somefield": "1234"
>   }
> ]
>
> Fix:
> # 952
> lookup(somefield,list.csv)
> marc_add('952',ind1,' ',ind2,' ',o,$.somefield)
>
> list.csv:
> 1234,"item.101"
> 1234,"item.102"
> 1234,"item.103"
>
> Output:
> =LDR
> =952  \\$0item.103
>
> However, the desired output is:
> =LDR
> =952  \\$oitem.101
> =952  \\$oitem.102
> =952  \\$oitem.103
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20170208/5b8dc14f/attachment.html>


More information about the librecat-dev mailing list