.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Catmandu::Fix::marc_map 3pm" .TH Catmandu::Fix::marc_map 3pm "2022-09-27" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Catmandu::Fix::marc_map \- copy marc values of one field to a new field .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& # Append all 245 subfields to my.title field the values are joined into one string \& marc_map(\*(Aq245\*(Aq,\*(Aqmy.title\*(Aq) \& \& # Append al 245 subfields to the my.title keeping all subfields as an array \& marc_map(\*(Aq245\*(Aq,\*(Aqmy.title\*(Aq, split:1) \& \& # Copy the 245\-$a$b$c subfields into the my.title hash in the order provided in the record \& marc_map(\*(Aq245abc\*(Aq,\*(Aqmy.title\*(Aq) \& \& # Copy the 245\-$c$b$a subfields into the my.title hash in the order c,b,a \& marc_map(\*(Aq245cba\*(Aq,\*(Aqmy.title\*(Aq, pluck:1) \& \& # Add the 100 subfields into the my.authors array \& marc_map(\*(Aq100\*(Aq,\*(Aqmy.authors.$append\*(Aq) \& \& # Add the 710 subfields into the my.authors array \& marc_map(\*(Aq710\*(Aq,\*(Aqmy.authors.$append\*(Aq) \& \& # Add the 600\-$x subfields into the my.subjects array while packing each into a genre.text hash \& marc_map(\*(Aq600x\*(Aq,\*(Aqmy.subjects.$append.genre.text\*(Aq) \& \& # Copy the 008 characters 35\-37 into the my.language hash \& marc_map(\*(Aq008/35\-37\*(Aq,\*(Aqmy.language\*(Aq) \& \& # Copy all the 600 fields into a my.stringy hash joining them by \*(Aq; \*(Aq \& marc_map(\*(Aq600\*(Aq,\*(Aqmy.stringy\*(Aq, join:\*(Aq; \*(Aq) \& \& # When 024 field exists create the my.has024 hash with value \*(Aqfound\*(Aq \& marc_map(\*(Aq024\*(Aq,\*(Aqmy.has024\*(Aq, value:found) \& \& # When 260c field exists create the my.has260c hash with value \*(Aqfound\*(Aq \& marc_map(\*(Aq260c\*(Aq,\*(Aqmy.has260c\*(Aq, value:found) \& \& # Copy all 100 subfields except the digits to the \*(Aqauthor\*(Aq field \& marc_map(\*(Aq100^0\-9\*(Aq,\*(Aqauthor\*(Aq) \& \& # Map all the 500 \- 599 fields to my.notes \& marc_map(\*(Aq5..\*(Aq,\*(Aqmy.motes\*(Aq) \& \& # Map the 100\-a field where indicator\-1 is 3 \& marc_map(\*(Aq100[3]a\*(Aq,\*(Aqname.family\*(Aq) \& \& # Map the 245\-a field where indicator\-2 is 0 \& marc_map(\*(Aq245[,0]a\*(Aq,\*(Aqtitle\*(Aq) \& \& # Map the 245\-a field where indicator\-1 is 1 and indicator\-2 is 0 \& marc_map(\*(Aq245[1,0]a\*(Aq,\*(Aqtitle\*(Aq) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Copy data from a \s-1MARC\s0 field to \s-1JSON\s0 path. .PP This module implements a small subset of the MARCspec specification to map \s-1MARC\s0 fields. For a more extensive \s-1MARC\s0 path implementation please take a look at Casten Klee's MARCSpec module: Catmandu::Fix::marc_spec .SH "METHODS" .IX Header "METHODS" .SS "marc_map(\s-1MARC_PATH, JSON_PATH, OPT:VAL, OPT2:VAL,...\s0)" .IX Subsection "marc_map(MARC_PATH, JSON_PATH, OPT:VAL, OPT2:VAL,...)" Copy the value(s) of the data found at a \s-1MARC_PATH\s0 to a \s-1JSON_PATH.\s0 .PP The \s-1MARC_PATH\s0 can point to a \s-1MARC\s0 field. For instance: .PP .Vb 2 \& marc_map(\*(Aq245\*(Aq,title) \& marc_map(\*(Aq020\*(Aq,isbn) .Ve .PP The \s-1MARC_PATH\s0 can point to one or more \s-1MARC\s0 subfields. For instamce: .PP .Vb 2 \& marc_map(\*(Aq245a\*(Aq,title) \& marc_map(\*(Aq245ac\*(Aq,title) .Ve .PP You can also use dollar signs to indicate subfields .PP .Vb 1 \& marc_map(\*(Aq245$a$c\*(Aq,title) .Ve .PP Wildcards are allowed in the field names: .PP .Vb 2 \& # Map all the 200\-fields to a title \& marc_map(\*(Aq2..\*(Aq\*(Aq,title) .Ve .PP To filter out specific fields indicators can be used: .PP .Vb 2 \& # Only map the MARC fields with indicator\-1 is \*(Aq1\*(Aq to title \& marc_map(\*(Aq245[1,]\*(Aq,title) .Ve .PP Also a substring of a field value can be mapped: .PP .Vb 2 \& # Map 008 position 35 to 37 to the language field \& marc_map(\*(Aq008/35\-37\*(Aq,language) .Ve .PP By default all matched fields in a \s-1MARC_PATH\s0 will be joined into one string. This behavior can be changed using one more more options (see below). .PP Visit our Wiki for a complete overview of all allowed mappings. .SH "OPTIONS" .IX Header "OPTIONS" .SS "split: 0|1" .IX Subsection "split: 0|1" When split is set to 1 then all mapped values will be joined into an array instead of a string. .PP .Vb 3 \& # The subject field will contain an array of strings (one string \& # for each 500 field found) \& marc_map(\*(Aq500\*(Aq,subject, split: 1) \& \& # The subject field will contain a string \& marc_map(\*(Aq500\*(Aq, subject) .Ve .SS "join: Str" .IX Subsection "join: Str" By default all the values are joined into a string without a field separator. Use the join function to set the separator. .PP .Vb 2 \& # All subfields of the 245 field will be separated with a space " " \& marc_map(\*(Aq245\*(Aq,title, join: " ") .Ve .SS "pluck: 0|1" .IX Subsection "pluck: 0|1" Be default, all subfields are added to the mapping in the order they are found in the record. Using the pluck option, one can select the required order of subfields to map. .PP .Vb 2 \& # First write the subfield\-c to the title, then the subfield_a \& marc_map(\*(Aq245ca\*(Aq,title, pluck:1) .Ve .SS "value: Str" .IX Subsection "value: Str" Don't write the value of the \s-1MARC\s0 (sub)field to the \s-1JSON_PATH\s0 but the specified string value. .PP .Vb 3 \& # has_024_a will contain the value \*(AqY\*(Aq if the MARC field 024 subfield\-a \& # exists \& marc_map(\*(Aq024a\*(Aq,has_024_a,value:Y) .Ve .SS "nested_arrays: 0|1" .IX Subsection "nested_arrays: 0|1" When the split option is specified the output of the mapping will always be an array of strings (one string for each subfield found). Using the nested_array option the output will be an array of array of strings (one array item for each matched field, one array of strings for each matched subfield). .SH "INLINE" .IX Header "INLINE" This Fix can be used inline in a Perl script: .PP .Vb 1 \& use Catmandu::Fix::marc_map as => \*(Aqmarc_map\*(Aq; \& \& my $data = { record => [...] }; \& \& $data = marc_map($data,\*(Aq245a\*(Aq,\*(Aqtitle\*(Aq); \& \& print $data\->{title} , "\en"; .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Catmandu::Fix Catmandu::Fix::marc_spec