[librecat-dev] fix alteration

Tiwe larsen tiwe.larsen at gmail.com
Fri Dec 9 09:44:34 CET 2016


Hello,


How could i alter the following fix, in order to get a report, that
would have as output,

for each value found in the csv, all ids of the mrc it is found?

The below fix, prints for each id, the values it has from the name
value csv file...


The CVS file looks like:

test.csv:

name,value
DLC,DLC
OCLC,OCLC


This fix file generates a report on all the MARC tags that have the $c
subfield matching the CVS file:

test.fix:

do marc_each()
  copy_field(record.0.0,test.name)
  marc_map(***c,test.value)
  lookup(test.value,test.csv,delete:1)
  if exists(test.value)
    copy_field(test,found.$append)
  end
  remove_field(test)
end

remove_field(record)

Run it as:

$ catmandu convert MARC to YAML --fix test.fix < camel.usmarc

The result produced, is

---
_id: '39'
found:
- name: '611'
  value: heritage
- name: '613'
  value: subject
- name: '620'
  value: iged
- name: '680'
  value: geo


How one can have an output like below?

something like for each value found in the csv,

print all ids it is found:

---
value : heritage

name : '611'

_id: '39'

name : '611'
_id: '140'

---
value : subject
name : '611'
_id: '39'

name : '611'
_id: '785'

---
...

Thank you very much
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20161209/48a30ab3/attachment.html>


More information about the librecat-dev mailing list