Patrick Hochstenbach > Catmandu-MARC > Catmandu::Importer::MARC

Download:
Catmandu-MARC-1.01.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 1.01   Source  

NAME ^

Catmandu::Importer::MARC - Package that imports MARC data

SYNOPSIS ^

    # From the command line convert MARC to JSON mapping 245a to a title
    $ catmandu convert MARC --fix "marc_map('245a','title')" < /foo/bar.mrc

    # From Perl
    use Catmandu;

    # import records from file
    my $importer = Catmandu->importer('MARC',file => '/foo/bar.mrc');
    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};
    });

DESCRIPTION ^

Catmandu::Importer::MARC is a Catmandu::Iterable to import MARC records from an external source. When given an input file an Catmandu::Iterable is create generating items as perl HASH-es containing two keys:

     '_id'    : the system identifier of the record (usually the 001 field)
     'record' : an ARRAY of ARRAYs containing the record data

Read more about processing data with Catmandu on the wiki: https://github.com/LibreCat/Catmandu/wiki

EXAMPLE ITEM ^

 {
  'record' => [
                      [
                        '001',
                        undef,
                        undef,
                        '_',
                        'fol05882032 '
                      ],
                      [
                        '245',
                        '1',
                        '0',
                        'a',
                        'Cross-platform Perl /',
                        'c',
                        'Eric F. Johnson.'
                      ],
              ],
  '_id' => 'fol05882032'
 }

CONFIGURATION ^

type

Create a new MARC importer of the given type. Currently we support:

file

Read input from a local file given by its path. Alternatively a scalar reference can be passed to read from a string.

fh

Read input from an IO::Handle. If not specified, Catmandu::Util::io is used to create the input stream from the file argument or by using STDIN.

encoding

Binmode of the input stream fh. Set to :utf8 by default.

fix

An ARRAY of one or more fixes or file scripts to be applied to imported items.

METHODS ^

Every Catmandu::Importer is a Catmandu::Iterable all its methods are inherited.

SEE ALSO ^

Catmandu::Importer, Catmandu::Iterable

syntax highlighting: