tcl-quill 0.3.0: Quill Project Automation System for Tcl/Tk

dictable(n): dictable formatting -- quill(n)

SYNOPSIS
DESCRIPTION
COMMANDS
AUTHOR
SEE ALSO

SYNOPSIS

package require quill 0.3.0
namespace import ::quill::*
dictable filter table key pattern ?key pattern...?
dictable format table ?options...?
dictable puts table ?options...?
dictable sort table ?colspecs?

DESCRIPTION

dictable(n) is a module for formatting plain text tables from lists of dictionaries. The primary constraint is that the dictionaries must all have the same keys (or the caller must limit the output to those keys the dictionaries have in common). It is intended primarily to simplify the creation of console output.

COMMANDS

dictable(n) defines the following commands:

dictable filter table key pattern ?key pattern...?
Returns a table containing all rows from table for which the given patterns match the given keys. The patterns are standard string match patterns.

dictable format table ?options...?
Given a "table", a list of dictionaries, this command formats the table as a multi-column table. Each dictionary is output on its own row, with one column for each dictionary key. There are no headers, and all keys are included; the order of the columns is the order of the keys in the first item in the table.

The following options may be used to customize the output:

-leader text
Specifies a leader string to put at the beginning of each line. To indent the table four spaces, use a leader of four spaces. Defaults to the empty string.

-sep text
Specifies the separator to go between columns. Defaults to one space character.

-columns list
Specifies a list of dictionary keys. The command will include just these keys in the output, in order from left to right.

-showheaders
If this option is given, the table will include column headers.

-skipsame list
If list is given, it should be a list of column names. If a named column has the same value in successive rows, it will be left blank in all rows but the first. This can result in more readable tables, especially when used for the first few columns.

-headers dict
By default, the column headers are simply the names of the column keys. If given, the value of -headers should be a dictionary of header label strings by column key.

dictable puts table ?options...?
Formats the table and writes it to stdout. The options are as for dictable format.

dictable sort table ?colspecs?
By default, this command sorts the rows in the table in increasing order using a case-sensitive string comparison on each column, taking the column order from the first row in the table. The sorting can be customized by specifying a list of column specifications. Each column spec is a list that begins with the column name; the columns are sorted in the order of the list. Each column spec may include the following options:

-decreasing
The column will be sorted in decreasing order, rather than increasing.

-nocase
String comparisons will be case insensitive.

-numeric
Values to be compared will be converted to numeric doubles before comparing.

For example,
set sorted [dictable sort $table {last first {age -numeric}}]

AUTHOR

Will Duquette

SEE ALSO

quill(n).
Generated from dictable.manpage on Sat Nov 08 09:38:04 PST 2014