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

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

πŸ’– Catman...RC::XML(3pm) πŸ’–

okay so bestie, welcome to the User Contributed Perl Documentation page for Catmandu::Importer::MARC::XML β€” section 3pm, library page, you know the vibe. pull up a chair, grab a boba, we're doing this πŸ§‹βœ¨


✨ NAME ✨

Catmandu::Importer::MARC::XML β€” the package that imports MARCXML records. that's it, that's the whole job, and it does it gorgeously πŸ’…


🌸 SYNOPSIS 🌸

here's the tea, two ways to do it. first, from the command line, like a main character:

# From the command line
$ catmandu convert MARC --type XML --fix "marc_map('245a','title')" < /foo/data.xml

then from perl, if that's more your era:

# From perl
use Catmandu;

# import records from file
my $importer = Catmandu->importer('MARC',file => '/foo/data.xml', type => 'XML');
my $fixer    = Catmandu->fixer("marc_map('245a','title')");

$importer->each(sub {
    my $item = shift;
    ...
});

# or using the fixer

$fixer->fix($importer)->each(sub {
    my $item = shift;
    printf "title: %s\n" , $item->{title};
});

the way that last one just fixes the importer and then iterates... obsessed 😭🫢


πŸŽ€ CONFIGURATION πŸŽ€

all the knobs and dials, no gatekeeping:

  • id β€” the MARC field that's holding the system id. default? 001. iconic of it honestly.
  • file β€” read your input from a local file, and you just hand it the path. or β€” plot twist β€” you can pass a scalar reference and read from a string instead. versatile queen πŸ’œ
  • fh β€” read input from an IO::Handle. if you don't specify one, Catmandu::Util::io gets drafted in to build the input stream from the "file" argument, or just from STDIN if you're feeling casual.
  • encoding β€” binmode of the input stream fh. it's set to ":utf8" by default, so like, it's already handled bestie.
  • fix β€” an ARRAY of one or more fixes or file scripts to apply to the imported items. stack 'em, layer 'em, slay ✨

πŸ”₯ METHODS πŸ”₯

real talk: every Catmandu::Importer is a Catmandu::Iterable, so all its methods are inherited. you don't need a separate list, you got the whole family tree for free πŸ‘‘


πŸ’« SEE ALSO πŸ’«

go read these next, they're the supporting cast:

  • Catmandu::Importer
  • Catmandu::Iterable

ngl there's nothing dangerous in here, it's just a very chill importer. no cap πŸ¦‹

and that's the page fr fr β€” brought to you by perl v5.38.2, dated 2024-08-03, and yes the footer really does call it Catman...RC::XML(3pm) again because it said it twice πŸ’€ we love a consistent queen. bye bestie, go import something cute πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from