Catman...RC::MiJ(3pm)

πŸ“¦
version 1.320 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Catmandu::Exporter::MARC::MiJ β€” bestie, it's the exporter that takes your MARC records and turns them into MARC in JSON πŸ’–

(yes, the manual page itself goes by Catman...RC::MiJ(3pm) β€” that's just its ✨ government name ✨, we don't use it in polite conversation πŸ’…)


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's how you actually use this thing, from the command line:

# From the command line
$ catmandu convert MARC --type XML to MARC --type MiJ < /foo/bar.xml

and here's the same glow-up from Perl, no cap:

# From Perl
use Catmandu;

my $importer = Catmandu->importer('MARC', file => "/foo/bar.xml" , type => 'XML');
my $exporter = Catmandu->exporter('MARC', file => "bar.json", type => 'MiJ' );

$exporter->add($importer);
$exporter->commit;

πŸŽ€ CONFIGURATION πŸŽ€

these are the knobs you can turn, and honestly each one is iconic in its own way:

  • file β€” write the output to a local file, given either by its path or by a file handle. alternatively? you can hand it a scalar reference and it'll write into a string instead, or a code reference and it'll write to a callback function. versatile queen πŸ‘‘
  • fh β€” write the output to an IO::Handle. if you don't specify one, Catmandu::Util::io gets recruited to build the output handle out of the file argument, or just falls back to STDOUT. she'll figure it out 🫢
  • fix β€” an ARRAY of one or more fixes or file scripts that get applied to the exported items. glow-up pass ✨
  • encoding β€” the binmode of the output stream fh. it's set to ":utf8" by default. πŸ’œ

πŸ’… METHODS πŸ’…

for the full menu of methods, go look at Catmandu::Exporter, Catmandu::Addable, Catmandu::Fixable, Catmandu::Counter, and Catmandu::Logger. that's the whole squad, they've got you covered 🫢


🌈 FORMAT 🌈

so the MARC-in-JSON record format has exactly two fields, and they are:

  • 'leader' β€” the MARC leader
  • 'fields' β€” an array of MARC fields

each item inside that MARC fields array holds the MARC tag, and as its value a hash with three fields in it:

  • 'subfields' β€” an array of MARC subfields
  • 'ind1' β€” the first indicator of the MARC tag
  • 'ind2' β€” the second indicator of the MARC tag

and each subfield item is a hash containing the MARC subfield tag and its value. nesting dolls but make it cataloguing πŸͺ†

here's what one MARC record looks like all dressed up in the MiJ serialization format:

{
  "leader": "0000cam  2200000   4500",
  "fields": [
    {
      "100": {
        "subfields": [
          {
            "a": "Huberman, Leo,"
          },
          {
            "d": "1903-1968."
          }
        ],
        "ind1": "1",
        "ind2": " "
      }
    },
    {
      "700": {
        "subfields": [
          {
            "a": "Sweezy, Paul M."
          },
          {
            "q": "(Paul Marlor),"
          },
          {
            "d": "1910-2004."
          }
        ],
        "ind1": "1",
        "ind2": " "
      }
    },
    ...
}

⭐ SEE ALSO ⭐

  • Catmandu::Exporter β€” go read it, it's giving main character energy πŸ‘‘

mwah, that's the whole page bestie πŸ’– this was documented with perl v5.38.2 on 2024-08-03, so if you're reading this from the future, hi, you're slaying 🫢✨

πŸ“¦ where this page comes from