[librecat-dev] bind for appending repeating MARC fields

Patrick Hochstenbach Patrick.Hochstenbach at UGent.be
Wed Feb 8 10:12:40 CET 2017


The semicolon at the end of `do` isn’t needed. It is a block statememt:  `do(..) FIX; FIX; FIX; end`:

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

> On 8 Feb 2017, at 06:48, Jason Loeffler <j at minorscience.com> wrote:
> 
> 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
> 
> _______________________________________________
> 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