IRIS Toolbox Reference Manual

## dbbatch

Run a batch job to create new database fields

#### Syntax

    [D,Processed,Added] = dbbatch(D,NewName,Expr,...)

#### Input arguments

- `D` [ struct ] - Input database.

- `NewName` [ char ] - Pattern that will be used to create names for new database fields based on the existing ones; use `'$0'` to refer to the name of the currently processed database field; use `'$1'`, `'$2'`, etc. to refer to tokens captured in regular expression specified in the `'namefilter='` option.

- `Expr` [ char ] - Expression that will be evaluated on a selection of existing database entries to create new database entries; the expression can include `'$0'`, `'$1'`, etc.

#### Output arguments

- `D` [ struct ] - Output database.

- `Processed` [ cellstr ] - List of database fields that have been used to create new fields.

- `Added` [ cellstr ] - List of new database fields created by evaluating `Expr` on the corresponding field in `Processed`.

#### Options

- `'classFilter='` [ char | `Inf` ] - From the existing database entries, select only those that are objects of the specified class or classes, and evaluate the expression `Expr` on these.

- `'fresh='` [ `true` | `false` ] - If true, the output database will only contain the newly created entries; if false the output database will also include all the entries from the input database.

- `'nameFilter='` [ char | empty ] - From the existing database entries, select only those that match this regular expression, and evaluate the expression `Expr` on these.

- `'nameList='` [ cellstr | `Inf` ] - Evaluate the `COMMAND` on this list of existing database entries.

- `'stringList='` [ cellstr | empty ] - Evaluate the expression `Expr` on this list of strings; the strings do not need to be names existing in the database; this options can be comined with `'nameFilter='`, `'nameList='`, and/or `'classFilter='` to narrow the selection.

#### Description

This function is primarily meant to create new database fields, each based on an existing one. If you, on the otherhand, only wish to modify a number of existing fields without adding any new ones, use `dbfun` instead.

The expression `Expr` is evaluated in the caller workspace, and hence may refer to any variables existing in the workspace, not only to the database and its fields.

To convert the strings `$0`, `$1`, `$2`, etc. to lower case or upper case, use the dot or colon syntax: `$.0`, `$.1`, `$.2` for ower case, and `$:0`, `$:1`, `$:2` for upper case.

#### Example

For each field (all assumed to be tseries) create a first difference, and name the new series `DX` where `X` is the name of the original series.

    d = dbbatch(d,'D$0','diff(d.$0)');

Note that the original series will be presered in the database, together with the newly created ones.

#### Example

Suppose that in database `D` you want to seasonally adjust all time series whose names end with `_u`, and give these seasonally adjusted series names without the _u.

    d = dbbatch(d,'$1','x12(d.$0)','nameFilter','(.*)u');

or, if you want to make sure only tseries objects will be selected (in case there are database entries ending with a `u` other than tseries objects)

    d = dbbatch(d,'$1','x12(d.$0)', ...
        'nameFilter=','(.*)u','classFilter=','tseries');

IRIS Toolbox. Copyright © 2007—2013 Jaromir Benes.