Package picalo :: Package base :: Module TableArray :: Class TableArray
[show private | hide private]
[frames | no frames]

Type TableArray

object --+    
         |    
      list --+
             |
            TableArray


Method Summary
  __init__(self, *args)
A list of picalo tables.
  __add__(self, other)
  __getitem__(self, index)
  __getslice__(self, i, j)
  __mul__(self, other)
  __setitem__(self, key, value)
  __setslice__(self, i, j, sequence)
  __sub__(self, other)
  append(self, value)
  append_calculated(self, name, expression)
Appends a calculated column to each table in the list.
  append_calculated_static(self, name, column_type, expression)
Appends a calculated column to each table in the list.
  append_column(self, name, column_type, values)
Adds a new column to each table in the list.
  clear_filter(self)
Clears any active filter to all tables in the list.
  column(self, col)
Returns the given column from the first table in this list.
  column_count(self)
Returns the column count from the first table in this list.
  combine(self)
Combines this table array into a single table.
  delete_column(self, column)
Deletes a column from each table in the list.
  filter(self, expression)
Applies the given filter to all tables in the list.
  get_column_names(self)
Returns the column names from the first table in this list.
  get_columns(self)
Returns the columns from the first table in this list.
  guess_types(self, num_records)
Guesses the column types for all tables in the list.
  insert_calculated(self, index, name, expression)
Inserts a calculated column to each table in the list.
  insert_calculated_static(self, index, name, column_type, expression)
Inserts a calculated column to each table in the list.
  insert_column(self, index, name, column_type, values)
Inserts a new column to each table in the list.
  is_changed(self)
Returns whether the table has been changed since loading
  is_filtered(self)
Returns whether the first table in this list is filtered.
  move_column(self, column, new_index)
Moves a column to another location for each table in the list.
  save(self, filename, respect_filter)
Saves this TableList in native Picalo format.
  save_csv(self, filename, line_ending, none, encoding, respect_filter)
Saves this TableList in CSV format.
  save_delimited(self, filename, delimiter, qualifier, line_ending, none, encoding, respect_filter)
Saves this TableList in delimited format.
  save_fixed(self, filename, line_ending, none, respect_filter)
Saves this TableList in fixed format.
  save_tsv(self, filename, line_ending, none, encoding, respect_filter)
Saves this TableList in tsv format.
  save_xml(self, filename, line_ending, indent, compact, none, respect_filter)
Saves this TableList in xml format.
  set_changed(self, changed)
Sets whether the class has been changed since loading.
  set_format(self, column, format)
Sets the format for a column in all tables in the list.
  set_name(self, column, name)
Sets the column name for all tables in the list.
  set_readonly(self, readonly_flag)
Sets the read only status of this table.
  set_type(self, column, column_type, format, expression)
Sets the column type for all tables in the list.
  structure(self)
Returns the structure of the first table in this list.
  view(self)
Opens the table list for viewing in the Picalo user interface.
  _check_valid_table(self, table)
Ensures that a given table is valid
    Inherited from list
  __contains__(x, y)
x.__contains__(y) <==> y in x
  __delitem__(x, y)
x.__delitem__(y) <==> del x[y]
  __delslice__(x, i, j)
Use of negative indices is not supported.
  __eq__(x, y)
x.__eq__(y) <==> x==y
  __ge__(x, y)
x.__ge__(y) <==> x>=y
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __gt__(x, y)
x.__gt__(y) <==> x>y
  __hash__(x)
x.__hash__() <==> hash(x)
  __iadd__(x, y)
x.__iadd__(y) <==> x+=y
  __imul__(x, y)
x.__imul__(y) <==> x*=y
  __iter__(x)
x.__iter__() <==> iter(x)
  __le__(x, y)
x.__le__(y) <==> x<=y
  __len__(x)
x.__len__() <==> len(x)
  __lt__(x, y)
x.__lt__(y) <==> x<y
  __ne__(x, y)
x.__ne__(y) <==> x!=y
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __repr__(x)
x.__repr__() <==> repr(x)
  __reversed__(...)
L.__reversed__() -- return a reverse iterator over the list
  __rmul__(x, n)
x.__rmul__(n) <==> n*x
  count(L, value)
L.count(value) -> integer -- return number of occurrences of value
  extend(...)
L.extend(iterable) -- extend list by appending elements from the iterable
  index(...)
L.index(value, [start, [stop]]) -> integer -- return first index of value
  insert(...)
L.insert(index, object) -- insert object before index
  pop(L, index)
L.pop([index]) -> item -- remove and return item at index (default last)
  remove(...)
L.remove(value) -- remove first occurrence of value
  reverse(...)
L.reverse() -- reverse *IN PLACE*
  sort(...)
L.sort(cmp=None, key=None, reverse=False) -- stable sort *IN PLACE*; cmp(x, y) -> -1, 0, 1
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__init__(self, *args)
(Constructor)

A list of picalo tables. Some functions in Picalo return a set of tables. Sets of tables are returned as TableArray objects. These objects have the exact same methods and behavior as typical Python lists.

For example, the Grouping.stratify_by_value() method stratifies a table into a number of smaller tables. These tables are returned in TableArray objects. You can access individual tables in a TableArray using the [n] notation.

Users do not normally create TableArrays. They are created automatically by Picalo functions.

TableArrays must hold the exact same type of table. For example, two tables in a given TableArray may not have different column names. If you need to hold a list of noncompatible tables (i.e. tables with different columns or types), use a regular python list [ ].

Example:
>>> data = Table([
...   ('id', int),
...   ('name', unicode),
... ],[
...   [ 1, 'Benny' ],
...   [ 2, 'Vijay' ],
... ])
>>> tables = Grouping.stratify_by_value(data, 'id')
>>> tables[0].view()
+----+-------+
| id |  name |
+----+-------+
|  1 | Benny |
+----+-------+

>>> tables[1].view()
+----+-------+
| id |  name |
+----+-------+
|  2 | Vijay |
+----+-------+

>>> for table in tables:
...   print len(table)        
...

1
1
Overrides:
__builtin__.list.__init__

append_calculated(self, name, expression)

Appends a calculated column to each table in the list. See the definition of this method in Table for more information.

append_calculated_static(self, name, column_type, expression)

Appends a calculated column to each table in the list. See the definition of this method in Table for more information.

append_column(self, name, column_type, values=None)

Adds a new column to each table in the list. See the definition of this method in Table for more information.

clear_filter(self)

Clears any active filter to all tables in the list. See the definition of this method in Table for more information.

column(self, col)

Returns the given column from the first table in this list. Since all tables have the same column definitions, it is comparable across all tables in the list.

column_count(self)

Returns the column count from the first table in this list. Since all tables have the same column definitions, it is comparable across all tables in the list.

combine(self)

Combines this table array into a single table. This is a kind of 'anti-stratification'.

delete_column(self, column)

Deletes a column from each table in the list. See the definition of this method in Table for more information.

filter(self, expression=None)

Applies the given filter to all tables in the list. See the definition of this method in Table for more information.

get_column_names(self)

Returns the column names from the first table in this list. Since all tables have the same column definitions, it is comparable across all tables in the list.

get_columns(self)

Returns the columns from the first table in this list. Since all tables have the same column definitions, it is comparable across all tables in the list.

guess_types(self, num_records=-1)

Guesses the column types for all tables in the list. See the definition of this method in Table for more information.

insert_calculated(self, index, name, expression)

Inserts a calculated column to each table in the list. See the definition of this method in Table for more information.

insert_calculated_static(self, index, name, column_type, expression)

Inserts a calculated column to each table in the list. See the definition of this method in Table for more information.

insert_column(self, index, name, column_type, values=None)

Inserts a new column to each table in the list. See the definition of this method in Table for more information.

is_changed(self)

Returns whether the table has been changed since loading

is_filtered(self)

Returns whether the first table in this list is filtered.

move_column(self, column, new_index)

Moves a column to another location for each table in the list. See the definition of this method in Table for more information.

save(self, filename, respect_filter=False)

Saves this TableList in native Picalo format. This is the preferred format to save TableLists in because all column types, formulas, and so forth are saved.
Parameters:
filename - The filename to save to. This can also be an open stream.
           (type=str @param respect_filter Whether to save the entire file or only those rows available through any current filters. @type respect_filter bool)

save_csv(self, filename, line_ending='\n', none='', encoding='utf-8', respect_filter=False)

Saves this TableList in CSV format. Since the table list probably has multiple tables in it, one CSV per table is created by prepending 1, 2, 3 to the filename.
Parameters:
filename - A file name or a file pointer to an open file. Using the file name string directly is suggested since it ensures the file is opened correctly for reading in CSV.
           (type=str)
line_ending - An optional line ending to separate rows with
           (type=str)
none - An optional parameter specifying what to write for cells that have the None value.
           (type=str)
encoding - The unicode encoding to use for international or special characters. For example, Microsoft applications like to use special characters for double quotes rather than the standard characters. Unicode (the default) handles these nicely.
           (type=str @param respect_filter Whether to save the entire file or only those rows available through any current filter. @type respect_filter bool)

save_delimited(self, filename, delimiter=',', qualifier='"', line_ending='\n', none='', encoding='utf-8', respect_filter=False)

Saves this TableList in delimited format. Since the table list probably has multiple tables in it, one delimited file per table is created by prepending 1, 2, 3 to the filename.
Parameters:
filename - A file name or a file pointer to an open file. Using the file name string directly is suggested since it ensures the file is opened correctly for reading in CSV.
           (type=str)
delimiter - An optional field delimiter character
           (type=str)
qualifier - An optional qualifier to use when delimiters exist in field values
           (type=str)
line_ending - An optional line ending to separate rows with
           (type=str)
none - An optional parameter specifying what to write for cells that have the None value.
           (type=str)
encoding - The unicode encoding to use for international or special characters. For example, Microsoft applications like to use special characters for double quotes rather than the standard characters. Unicode (the default) handles these nicely.
           (type=str @param respect_filter Whether to save the entire file or only those rows available through any current filter. @type respect_filter bool)

save_fixed(self, filename, line_ending='\n', none='', respect_filter=False)

Saves this TableList in fixed format. Since the table list probably has multiple tables in it, one fixed file per table is created by prepending 1, 2, 3 to the filename.
Parameters:
filename - A file name or a file pointer to an open file. Using the file name string directly is suggested since it ensures the file is opened correctly for reading in CSV.
           (type=str)
line_ending - An optional line ending to separate rows with
           (type=str)
none - An optional parameter specifying what to write for cells that have the None value.
           (type=str @param respect_filter Whether to save the entire file or only those rows available through any current filter. @type respect_filter bool)

save_tsv(self, filename, line_ending='\n', none='', encoding='utf-8', respect_filter=False)

Saves this TableList in tsv format. Since the table list probably has multiple tables in it, one tsv file per table is created by prepending 1, 2, 3 to the filename.
Parameters:
filename - A file name or a file pointer to an open file. Using the file name string directly is suggested since it ensures the file is opened correctly for reading in CSV.
           (type=str)
line_ending - An optional line ending to separate rows with
           (type=str)
none - An optional parameter specifying what to write for cells that have the None value.
           (type=str)
encoding - The unicode encoding to use for international or special characters. For example, Microsoft applications like to use special characters for double quotes rather than the standard characters. Unicode (the default) handles these nicely.
           (type=str)

save_xml(self, filename, line_ending='\n', indent='\t', compact=False, none='', respect_filter=False)

Saves this TableList in xml format. Since the table list probably has multiple tables in it, one xml file per table is created by prepending 1, 2, 3 to the filename.
Parameters:
filename - A file name or a file pointer to an open file. Using the file name string directly is suggested since it ensures the file is opened correctly for reading in CSV.
           (type=str)
line_ending - An optional line ending to separate rows with (when compact is False)
           (type=str)
indent - The character(s) to use for indenting (when compact is False)
           (type=str)
compact - Whether to compact the XML or make it "pretty" with whitespace
           (type=bool)
none - An optional parameter specifying what to write for cells that have the None value.
           (type=str @param respect_filter Whether to save the entire file or only those rows available through any current filter. @type respect_filter bool)

set_changed(self, changed)

Sets whether the class has been changed since loading. This is not normally called by users.

set_format(self, column, format=None)

Sets the format for a column in all tables in the list. See the definition of this method in Table for more information.

set_name(self, column, name)

Sets the column name for all tables in the list. See the definition of this method in Table for more information.

set_readonly(self, readonly_flag=False)

Sets the read only status of this table. Tables that are read only cannot be modified. Normally, tables are initially not read only (i.e. can be modified). The only exception is tables loaded from databases, which are read only.
Parameters:
readonly_flag - True or False, depending upon whether the table should be read only or not.
           (type=bool)

set_type(self, column, column_type=None, format=None, expression=None)

Sets the column type for all tables in the list. See the definition of this method in Table for more information.

structure(self)

Returns the structure of the first table in this list. Since all tables have the same column definitions, it is comparable across all tables in the list.

view(self)

Opens the table list for viewing in the Picalo user interface. The resulting view allows you to page through the tables in the list. See the first example.

You can view individual tables in the list by using the [n] notation. See the second example for this notation.

Example:
>>> data = Table([
...   ('id', int),
...   ('name', unicode),
... ],[
...   [ 1, 'Benny' ],
...   [ 2, 'Vijay' ],
... ])
>>> tables = Grouping.stratify_by_value(data, 'id')
>>> tables.view()
Example:
>>> data = Table([
...   ('id', int),
...   ('name', unicode),
... ],[
...   [ 1, 'Benny' ],
...   [ 2, 'Vijay' ],
... ])
>>> tables = Grouping.stratify_by_value(data, 'id')
>>> tables[0].view()

_check_valid_table(self, table)

Ensures that a given table is valid

Generated by Epydoc 2.1 on Mon Aug 20 05:38:17 2007 http://epydoc.sf.net