[librecat-dev] retrieving MARC subfields with marc_map

Uldis Bojars captsolo at gmail.com
Tue Jul 4 15:27:16 CEST 2017


Hi,

Reporting back on retrieving "raw" subfield information from MARC records:

When you need to retrieve specific subfields from a MARC record (e.g. to
get an array from field 246 with separate subfields $a, $n and $p) it is
important to use the option "pluck:1" with marc_map():

Input data:

      [

         "246",

         "3",

         "0",

         "a",

         "Villa \" Palsais zirgs \"",

         "n",

         "Lala nnn"

      ],

      [

         "246",

         "3",

         "0",

         "a",

         "Imperatora tabakdoze",

         "p",

         "LuLu ppp"

      ]

Without "pluck:1" = marc_map('246anp', f246_temp_1, split:1,
nested_arrays:1) :

   "f246_temp_1" : [

      [

         "Villa \" Palsais zirgs \"",

         "Lala nnn"

      ],

      [

         "Imperatora tabakdoze",

         "LuLu ppp"

      ]

   ]

Notice that you can not tell any more what information was in which
subfield (both "Lala nnn" and "LuLu ppp" are 2nd elements of the respective
arrays though these are values of two different subfields).

This can be fixed using "pluck:1" - but only in case if there are no
repeated subfields:

marc_map('246anp', f246_temp_2, split:1, nested_arrays:1, pluck:1)

   "f246_temp_2" : [

      [

         [

            "Villa \" Palsais zirgs \"",

            "Lala nnn",

            null

         ],

         [

            "Imperatora tabakdoze",

            null,

            "LuLu ppp"

         ]

      ]

Now you can tell (from the array position) what was the value of each
subfield.

This is an important difference but it is not directly mentioned in the
documentation. I would have missed it if not for Patrick's answer
to trmurakami's question at
http://librecat.org/catmandu/2013/06/21/catmandu-cheat-sheet.html

Would it be possible to add this to the documentation?

Cheers,
Uldis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20170704/e501cd3a/attachment.html>


More information about the librecat-dev mailing list