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

Module picalo.base.Table

Classes
Table The primary data structure used in Picalo modules.
TableDataPageFile A single page file on disk
UnicodeCSVReader  
UnicodeCSVWriter  

Function Summary
  convert_to_str(val)
Table or TableList or TableArray load(filename)
Loads a native picalo file.
Table load_csv(filename, header_row, none)
Loads records from a Comma Separated Values (CSV) file.
Table load_delimited(filename, header_row, delimiter, qualifier, none)
Loads records from the given delimited text file.
Table load_excel(filename, worksheet_name, topleft_cell, bottomright_cell, header_row, none)
Loads the given Excel file.
Table load_fixed(filename, column_positions, header_row, none)
Loads records from a fixed width file.
Table load_tsv(filename, header_row, none)
Loads records from a Excel Tab Separated Values (TSV) file.
  save(table, filename, respect_filter)
Saves this table in native Picalo format.
  TableIterator(table, respect_filter)
Returns a generator object to iterate over a table
  view(table)
Opens a spreadsheet-view of the table if Picalo is being run in GUI mode.
  _load_dialect(filename, dialect, header_row, none)
Loads a CSV dialect into a table.
  _loadVersion1(gin)
Internal method to load version 1 (this would take less memory with sax, but that can be done another day)
  _saveVersion1(table, gout, respect_filter)
Internal method to save version 1

Variable Summary
dict bomDict = {(255, 254, None): 'utf_16_le', (239, 187, 191...
int PAGE_FILE_SIZE = 2147483647                                                            
int PICKLE_PROTOCOL = 2                                                                     
str TABLE_PAGE_DIR = '/tmp'
str TABLE_PAGE_EXT = '.picalo_temp_page_file'

Function Details

load(filename)

Loads a native picalo file. Determines the version of the picalo file, then calls the appropriate load routine for that version.
Parameters:
filename - The name of the file to load. This can also be an open stream.
           (type=str)
Returns:
A Picalo table containing the data from the file.
           (type=Table or TableList or TableArray)

load_csv(filename, header_row=True, none='')

Loads records from a Comma Separated Values (CSV) file. Among the various CSV flavors in the world, this function uses the Microsoft version.
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)
header_row - Whether the first line of the file includes the column names. Most delimited text files do this.
           (type=str)
none - An optional argument that specifies the record to assign Python's None type to (for blank cells).
           (type=str)
Returns:
A new Table object, or None if the file is empty.
           (type=Table)

load_delimited(filename, header_row=True, delimiter=',', qualifier='"', none='')

Loads records from the given delimited text file. This function allows the specification of delimiters and qualifiers. Most users should use the load_csv, load_tsv, and load_fixed functions as they provide easier access to text files. Use this function only if you have a specially-formatted text file.
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)
header_row - Whether the first line of the file includes the column names. Most delimited text files do this.
           (type=str)
delimiter - An optional field delimiter character
           (type=str)
qualifier - An optional qualifier to use when delimiters exist in field records
           (type=str)
none - An optional argument that specifies the record to assign Python's None type to (for blank cells).
           (type=str)
Returns:
A new Table object, or None if the file is empty.
           (type=Table)

load_excel(filename, worksheet_name=None, topleft_cell=None, bottomright_cell=None, header_row=True, none='')

Loads the given Excel file. Values are taken from the first sheet in the workbook.
Parameters:
filename - The file name. It must be the string name and not a file pointer (the library doesn't support it).
           (type=str)
worksheet_name - The name of the worksheet that contains the data (only one worksheet can be imported). Defaults to the first sheet in the workbook.
           (type=str)
topleft_cell - The top-left cell of the block to import. It should be in spreadsheet format, such as "A2" or "C5". Defaults to the first cell with data.
           (type=str)
bottomright_cell - The bottom-right cell of the block to import. It should be in spreadsheet format, such as "A2" or "C5". Defaults to the last cell with data.
           (type=str)
header_row - Whether the first line of the file includes the column names. Defaults to True.
           (type=str)
none - An optional argument that specifies the record to assign Python's None type to (for blank cells).
           (type=str)
Returns:
A new Table object, or None if the file is empty.
           (type=Table)

load_fixed(filename, column_positions, header_row=True, none='')

Loads records from a fixed width file. Fixed width files pad columns with extra spaces so they are easy to read with a text editor.
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)
column_positions - A list of integers specifying where to split columns. The first record should always be 0 (the first character in each line).
           (type=list)
header_row - An optional parameter to specify whether the first row of the file contains field headers. Defaults to True.
           (type=bool)
none - An optional argument that specifies the record to assign Python's None type to (for blank cells).
           (type=str)
Returns:
A new Table object, or None if the file is empty.
           (type=Table)

load_tsv(filename, header_row=True, none='')

Loads records from a Excel Tab Separated Values (TSV) file. Among the various TSV flavors in the world, this function uses the Microsoft version.
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)
header_row - Whether the first line of the file includes the column names. Most delimited text files do this.
           (type=str)
none - An optional argument that specifies the record to assign Python's None type to (for blank cells).
           (type=str)
Returns:
A new Table object, or None if the file is empty.
           (type=Table)

save(table, filename, respect_filter=False)

Saves this table in native Picalo format. This is the preferred format to save tables 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 filter. @type respect_filter bool)

TableIterator(table, respect_filter=True)

Returns a generator object to iterate over a table

view(table)

Opens a spreadsheet-view of the table if Picalo is being run in GUI mode. If Picalo is being run in console mode, it redirects to prettyprint(). This is the preferred way of viewing the data in a table.

_load_dialect(filename, dialect, header_row=1, none='')

Loads a CSV dialect into a table. See the csv module docs for more info

_loadVersion1(gin)

Internal method to load version 1 (this would take less memory with sax, but that can be done another day)

_saveVersion1(table, gout, respect_filter=False)

Internal method to save version 1

Variable Details

bomDict

Type:
dict
Value:
{(239, 187, 191): 'utf_8',
 (254, 255, None): 'utf_16_be',
 (254, 255, 0): 'utf_16',
 (255, 254, None): 'utf_16_le'}                                        

PAGE_FILE_SIZE

Type:
int
Value:
2147483647                                                            

PICKLE_PROTOCOL

Type:
int
Value:
2                                                                     

TABLE_PAGE_DIR

Type:
str
Value:
'/tmp'                                                                 

TABLE_PAGE_EXT

Type:
str
Value:
'.picalo_temp_page_file'                                               

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