NAME

rdbrowop - perform arithmetic operations between rows within a column


SYNOPSIS

rdbrowop options < input stream > output stream [columns]

rdbrowop --input=input stream --output=output stream [columns]


DESCRIPTION

rdbrowop performes arithmetic and cumulative arithmetic operations within a column between the values in adjacent rows.

The input and output RDB tables are by default read and written to the standard input and output streams, but may be specified via the --input and --output command line options.

By default all columns are operated on; to operate on only a subset, specify them as individual arguments at the end of the command line. Regular expressions may be used to select columns; see the --re and --RE options.

The results are written as new columns to the table. See the --prefix option for how they are named. In the case of simple arithmetic operations, two columns are produced for each input column:

  value(next row)    OP value(current row)
  value(current row) OP value(previous row)

The values stored in the first row are

  value(second row) OP value(first row)
  value(second row) OP value(first row)

Values stored in the last row are

  value(last row) OP value(next to last row)
  value(last row) OP value(next to last row)

For cumulative operations, a single new column is produced:

  value(current row) OP value(previous row)

For the first row multiplicative operations use 1 as the previous value; additive operations use 0 as the previous value.


OPTIONS AND ARGUMENTS

Options are specified using a UNIX getopt style interface. Long names are available when preceded with double hyphens ``--'', in which case only the minimal number of characters are required. Options which take values may be separated from those values with either white space or the ``='' character.

--input=input
The input RDB table. By default, the input table is read from the standard input stream.

--output=output
The output RDB table. By default, the output table is written to the standard output stream.

--prefix|--pfx = prefix
Column names for the new output columns are created by applying a prefix to the input column names and, in the case of simple arithmetic operators, additional suffices.

This option allows the specification of the prefix; it defaults to d_.

The suffices are hardwired as _p and _n, for the values of operations with the previous and next rows, respectively.

--re
This option indicates that the column names specified on the command line are to be treated as Perl regular expressions.

--RE
This flag should precede column names which should be treated as Perl regular expressions. This is useful when not all column names are regular expressions (as would be indicated by using --re).

--op=operand
This specifies which operation to perform. Valid simple arithmetic operations are:
   + - / *

Cumulative operations are:

   += -= /= *=

--help
Print short help information and exit.

--usage
Print long usage information and exit.

--version
Print the version of the program and exit.

--debug|--x
Print debugging information.


EXAMPLES


BUGS AND LIMITATIONS

rdbrowop uses the RDB Perl class, and so isn't as fast as it might be.


AUTHOR

Diab Jerius <djerius@cfa.harvard.edu>


COPYRIGHT AND LICENSE

Copyright (C) 2004 by the Smithsonian Astrophysical Observatory

This software is released under the GNU General Public License. You may find a copy at http://www.fsf.org/copyleft/gpl.html.