Home  

Neosynapse Downloads
Neosynapse About Neosynapse Case Studies Custom Solutions Open Source Contact Us


Hierarchical Tables


The mix_table module provides a hierarchical_table class which allows easy handling of table data types. Tables look superficially like a list of dictionaries. Thus, the seventh item (zero-indexed) can be referenced as:


>>> table[ 6 ]

...and the column 'foo' in that item can be referenced as:

>>> table[ 6 ][ 'foo' ]

However, hierarchical_tables support many powerful features that make dealing with tabular structures easy. Like a dictionary, you can see all column names. The structure takes normalization steps to ensure that all rows have all the columns in the table, even if the values are empty. Rows may be inserted, appended and deleted. A table may be sorted, alphabetically or numerically, ascending or descending, along one or more columns. Columns may be fetched as a list of values using the get_column* functions.

Tables can be compared as sets to other tables, allowing one to determine whether a table is a subset or a superset of another table. Finally, tables can be indexed along one or more columns. When this happens, an index object is returned which acts like a dictionary; the keys are the distinct combinations of the columns specified, and the value is the list of rows that have each distinct key value.

See the regression tests for some examples of how to use hierarchical_table. The mix_table module, of which the hierarchical_table class is a part, can be downloaded from http://www.neosynapse.net/downloads/mix_table.tar.gz.

 



About Neosynapse / Custom Solutions / Open Source / Contact Us
Copyright © Neosynapse 2003-2005