DESCRIPTION

Catmandu provides a command line client and a Perl API to ease the export (E) transformation (T) and loading (L) of data into databases or data file, ETL in short.

Most of the daily work processing structured data can be done on the command line executing the catmandu command. With our catmandu command ETL processing is available in a Perl context. Catmandu is different from other ETL tools by its focus on command line processing with much support for dataformats available in (academic) libraries: MARC, MODS, OAI and SRU. But, also generic formats such as JSON, YAML, CVS, Excel, XML, RDF, Atom are supported.

The documentation below describes the methods available when including Catmandu as part of a Perl script. For an overview of the command line tool itself read the documentation on catmandu.

USE

To include Catmandu in a Perl script it should be loaded with a use command:

use Catmandu;

By default no methods are imported into the Perl context. To import all or some Catmandu methods, provide them as a list to the use command:

use Catmandu -all;
use Catmandu qw(config store exporter);

Catmandu can load configuration options for exports, importers, fixers via configuration files (see the CONFIG section below). When adding the --load option (optionally with a path) to the use command, these configuration files will be loaded at the start of your script.

use Catmandu -load;
use Catmandu --load => ['/my/config/directory'];
# or use all the options
use Catmandu -all -load => [qw(/config/path' '/another/config/path)];

default_load_path(['/default/path'])

Returns the default location where Catmandu looks for configuration and lib when called with no argument. Sets the default location if a path is given. The default load path is the script directory or it's parent if the script directory is bin.

load

Load all the configuration options in the catmandu.yml configuration file. See CONFIG below for extended examples of configuration options.

load('/path', '/another/path')

Load all the configuration options stored at alternative paths.

A load path ':up' will search upwards from your program for configuration.

See CONFIG below for extended examples of configuration options.

roots

Returns an ARRAYREF of paths where configuration was found. Note that this list is empty before load.

root

Returns the first path where configuration was found. Note that this is undef before load.

config

Returns the current configuration as a HASHREF.

config($config)

Set a new configuration and reload the environment.

default_store

Return the name of the default store.

store([NAME])

Return an instance of Catmandu::Store. The NAME is a name of a Catmandu::Store or the name of a store configured in a catmandu.yml configuration file. When no NAME is given, the 'default' store in the configuration file will be used.

# This will use ElasticSearch
my $store = Catmandu->store('ElasticSearch', index_name => 'blog');
# or because we have a 'default' set in the configuration file
my $store = Catmandu->store('default');
# or because 'default' will be used when no name was provided
my $store = Catmandu->store;
# This will use Mock
my $store = Catmandu->store('test');

Configuration settings can be overwritten by the store command:

my $store2 = Catmandu->store('default', index_name => 'test2');

default_fixer

Return the name of the default fixer.

fixer(NAME)

fixer(FIX,FIX)

fixer([FIX])

Return an instance of Catmandu::Fix. NAME can be the name of a fixer section in a catmandu.yml file. Or, one or more Catmandu::Fix-es can be provided inline.

FIX-es can be also written to a Fix script. E.g. if myfixes.txt contains:

do_this()
do_that()

then the above code will even be equivalent to:

my $fixer = Catmandu->fixer('myfixes.txt');

default_importer

Return the name of the default importer.

default_importer_package

Return the name of the default importer package if no package name is given in the config or as a param.

importer(NAME)

Return an instance of Catmandu::Importer. The NAME is a name of a Catmandu::Importer or the name of a importer configured in a catmandu.yml configuration file. When no NAME is given, the 'default' importer in the configuration file will be used.

use Catmandu -load;
use Catmandu -load => [];
# is the same as
Catmandu->load;
use Catmandu -load => ['/config/path'];
# is the same as
Catmandu->load('/config/path');

CONFIG

Catmandu configuration options can be stored in files in the root directory of your programming project. The file can be YAML, JSON or Perl and is called catmandu.yml, catmandu.json or catmandu.pl. In this file you can set the default Catmandu stores and exporters to be used. Here is an example of a catmandu.yml file:

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.