Previous Next blank.gif blank.gif

Class DataList - Class supporting tabular storage and access of data.


SYNOPSIS

import barchart
class DataList(UserList)
  def __init__(self, list = None)
  string __module__ = 'barchart'
  def __str__(self)
  def add_column(self, name, pairs)
  def cache_labels(self)
  def decreasing(self, a, b)
  def increasing(self, a, b)
  def index(self, label)
  def load_tuple(self, t)
  def load_tuples(self, tt)
  def max(self, key='value')
  def mean(self, key='value')
  def min(self, key='value')
  tuple segment_names = ('value',)
  def sort(self, key='label', direction='increasing')
  def sum(self, key='value')
  def sum_totals(self)

  # Methods inherited by DataList from UserList
  def __add__(self, list)
  def __cmp__(self, list)
  def __delitem__(self, i)
  def __delslice__(self, i, j)
  def __getitem__(self, i)
  def __getslice__(self, i, j)
  def __len__(self)
  def __mul__(self, n)
  def __mul__(self, n)
  def __radd__(self, list)
  def __repr__(self)
  def __setitem__(self, i, item)
  def __setslice__(self, i, j, list)
  def append(self, item)
  def count(self, item)
  def insert(self, i, item)
  def pop(self, i=-1)
  def remove(self, item)
  def reverse(self)

DESCRIPTION

Used by BarChart classes. Takes a list of sequences and loads them into a list of dictionaries using the first item from the sequence as a label key. The column names are from the segment_names attribute and must be set prior to loading multidimensional data.

Supports some simple data processing methods.

def __str__(self)

Return tabular string representation of internal data.

def add_column(self, name, pairs)

Take list of (label,value) pairs and add the data as a new column named name.

def cache_labels(self)

Create cache of indexes corresponding to the labels to speed calles to index method.

def index(self, label)

return dictionary corresponding to label string.

def load_tuple(self, t)

Load individual record of data into new dictionary.

Use first item in given sequence as label key and assigns remaining items with keys from segment_names in order.

def load_tuples(self, tt)

Load each item from the given sequence of sequences.

def max(self, key='value')

return maximum value in column key

def mean(self, key='value')

return mean (average) of values in column key

def min(self, key='value')

return minimum value in column key

def sort(self, key='label', direction='increasing')

Sort list according to key in direction.

Example: DLobject.sort(height , 'decreasing')

def sum(self, key='value')

return sum of values in column key

def sum_totals(self)

add new key total to each dictionary

SEE ALSO

barchart

UserList


Previous Next blank.gif blank.gif
Buzz.gif

Copyright © Robin Friedrich
All Rights Reserved
Comments to author: dev@null
Generated: Tue Apr 20, 1999