Previous: Control Transformations, Up: Basic Transformations



7.1.4 Output Transformations

The output transformations are echo, die, csv, and describe.

echo
die
echo and die take an arbitrary number of arguments, perform global replacement on them, and then print the result. Die uses Perl's die command to print the result on stderr and execution halts.
csv
Produces a CSV file on stdout that represents the current relation. This transform takes no arguments.
describe
The describe transformation creates tabular reports, like those in Tabular Reports. The arguments to describe are the names of columns to print. For example describe(["NAME", "MEAN"]); when applied to descrel prints out the following table:
          NAME     MEAN
          fruzzles   16
          widgets     3
     

fruzzles widgets
12 3
21 7
15 8

Relation 7.14

The value of each part of the table is determined by performing column replacement on the variable $globals{'colexpr'}->{$colname}. For more information on replacement, See Replacements. This gives you quite a bit of power when deciding what to print.

There are three other global parameters that control the describe output: spacing, delimiter, and precision. spacing determines the number of spaces between each column. If set to zero, there are no spaces between each column (e.g., fruzzles16). If delimiter is set, then it is printed between each column. For example, if delimiter is , and spacing is zero, the first row would be fruzzles,16. The final value of interest is precision, which specifies how many digits after the decimal point are printed for floating point values.

The set transformation can be used to set spacing, delimiter, and precision. To set values in the colexpr hash, you should use "eval" to modify individual elements or "seteval" to replace the whole hash.

dump
Writes a table of the current relation to stdout. This transform takes no arguments, but uses the global variables delimiter, precision, and spacing to control the output.