gbv / Catmandu-PICA

Catmandu modules for working with PICA+ data
https://metacpan.org/release/Catmandu-PICA
Other
4 stars 4 forks source link

pica_add for PICA+ 237A$a #87

Closed martinasiebert closed 1 year ago

martinasiebert commented 1 year ago

catmandu fix for conversion to PICA seems not to know about that PICA field when using pica_add

nichtich commented 1 year ago

Confirmed test:

echo '{"x":1,"record":[["012X","","x","a"]]}' | catmandu convert JSON to PICA --fix 'pica_add(x,237X$a)'
nichtich commented 1 year ago

It turns out, this is not a bug because 237A is not 237A/00 but a shortcut for 237A/* (all 237A fields with any occurence). So this works for existing fields 237A/*:

echo '{"x":1,"record":[["237X","01","x","a"]]}' | catmandu convert JSON to PICA --fix 'pica_add(x,237X$a)'

To add a new field, the occurrence must be known, e.g.

echo '{"x":1,"record":[["003@","","0","123"]]}' | catmandu convert JSON to PICA --fix 'pica_add(x,237X/01$a)'

By the way I just release 1.14 fixing #77, so after update this should also work.

echo '{"x":1}' | catmandu convert JSON to PICA --fix 'pica_add(x,237X/01$a)'

If further help is needed, please describe your use case!