Module prettytable :: Class PrettyTable
[hide private]
[frames] | no frames]

Class PrettyTable

source code

object --+
         |
        PrettyTable

Instance Methods [hide private]
 
__init__(self, field_names=None, **kwargs)
Return a new PrettyTable instance
source code
 
_unicode(self, value) source code
 
_justify(self, text, width, align) source code
 
__getattr__(self, name) source code
 
__getitem__(self, index) source code
 
__str__(self)
str(x)
source code
 
__unicode__(self) source code
 
_validate_option(self, option, val) source code
 
_validate_field_names(self, val) source code
 
_validate_header_style(self, val) source code
 
_validate_align(self, val) source code
 
_validate_valign(self, val) source code
 
_validate_nonnegative_int(self, name, val) source code
 
_validate_true_or_false(self, name, val) source code
 
_validate_int_format(self, name, val) source code
 
_validate_float_format(self, name, val) source code
 
_validate_function(self, name, val) source code
 
_validate_hrules(self, name, val) source code
 
_validate_vrules(self, name, val) source code
 
_validate_field_name(self, name, val) source code
 
_validate_all_field_names(self, name, val) source code
 
_validate_single_char(self, name, val) source code
 
_validate_attributes(self, name, val) source code
 
_get_field_names(self) source code
 
_set_field_names(self, val) source code
 
_get_align(self) source code
 
_set_align(self, val) source code
 
_get_valign(self) source code
 
_set_valign(self, val) source code
 
_get_max_width(self) source code
 
_set_max_width(self, val) source code
 
_get_fields(self)
List or tuple of field names to include in displays
source code
 
_set_fields(self, val) source code
 
_get_start(self)
Start index of the range of rows to print
source code
 
_set_start(self, val) source code
 
_get_end(self)
End index of the range of rows to print
source code
 
_set_end(self, val) source code
 
_get_sortby(self)
Name of field by which to sort rows
source code
 
_set_sortby(self, val) source code
 
_get_reversesort(self)
Controls direction of sorting (ascending vs descending)
source code
 
_set_reversesort(self, val) source code
 
_get_sort_key(self)
Sorting key function, applied to data points before sorting
source code
 
_set_sort_key(self, val) source code
 
_get_header(self)
Controls printing of table header with field names
source code
 
_set_header(self, val) source code
 
_get_header_style(self)
Controls stylisation applied to field names in header
source code
 
_set_header_style(self, val) source code
 
_get_border(self)
Controls printing of border around table
source code
 
_set_border(self, val) source code
 
_get_hrules(self)
Controls printing of horizontal rules after rows
source code
 
_set_hrules(self, val) source code
 
_get_vrules(self)
Controls printing of vertical rules between columns
source code
 
_set_vrules(self, val) source code
 
_get_int_format(self)
Controls formatting of integer data Arguments:
source code
 
_set_int_format(self, val) source code
 
_get_float_format(self)
Controls formatting of floating point data Arguments:
source code
 
_set_float_format(self, val) source code
 
_get_padding_width(self)
The number of empty spaces between a column's edge and its content
source code
 
_set_padding_width(self, val) source code
 
_get_left_padding_width(self)
The number of empty spaces between a column's left edge and its content
source code
 
_set_left_padding_width(self, val) source code
 
_get_right_padding_width(self)
The number of empty spaces between a column's right edge and its content
source code
 
_set_right_padding_width(self, val) source code
 
_get_vertical_char(self)
The charcter used when printing table borders to draw vertical lines
source code
 
_set_vertical_char(self, val) source code
 
_get_horizontal_char(self)
The charcter used when printing table borders to draw horizontal lines
source code
 
_set_horizontal_char(self, val) source code
 
_get_junction_char(self)
The charcter used when printing table borders to draw line junctions
source code
 
_set_junction_char(self, val) source code
 
_get_format(self)
Controls whether or not HTML tables are formatted to match styling options
source code
 
_set_format(self, val) source code
 
_get_print_empty(self)
Controls whether or not empty tables produce a header and frame or just an empty string
source code
 
_set_print_empty(self, val) source code
 
_get_attributes(self)
A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML
source code
 
_set_attributes(self, val) source code
 
_get_options(self, kwargs) source code
 
set_style(self, style) source code
 
_set_default_style(self) source code
 
_set_msword_style(self) source code
 
_set_columns_style(self) source code
 
_set_random_style(self) source code
 
add_row(self, row)
Add a row to the table
source code
 
del_row(self, row_index)
Delete a row to the table
source code
 
add_column(self, fieldname, column, align='c', valign='t')
Add a column to the table.
source code
 
clear_rows(self)
Delete all rows from the table but keep the current field names
source code
 
clear(self)
Delete all rows and field names from the table, maintaining nothing but styling options
source code
 
copy(self) source code
 
_format_value(self, field, value) source code
 
_compute_widths(self, rows, options) source code
 
_get_padding_widths(self, options) source code
 
_get_rows(self, options)
Return only those data rows that should be printed, based on slicing and sorting.
source code
 
_format_row(self, row, options) source code
 
_format_rows(self, rows, options) source code
 
get_string(self, **kwargs)
Return string representation of table in current state.
source code
 
_stringify_hrule(self, options) source code
 
_stringify_header(self, options) source code
 
_stringify_row(self, row, options) source code
 
get_html_string(self, **kwargs)
Return string representation of HTML formatted version of table in current state.
source code
 
_get_simple_html_string(self, options) source code
 
_get_formatted_html_string(self, options) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]
  field_names
  align
  valign
  max_width
  fields
List or tuple of field names to include in displays
  start
Start index of the range of rows to print
  end
End index of the range of rows to print
  sortby
Name of field by which to sort rows
  reversesort
Controls direction of sorting (ascending vs descending)
  sort_key
Sorting key function, applied to data points before sorting
  header
Controls printing of table header with field names
  header_style
Controls stylisation applied to field names in header
  border
Controls printing of border around table
  hrules
Controls printing of horizontal rules after rows
  vrules
Controls printing of vertical rules between columns
  int_format
Controls formatting of integer data Arguments:
  float_format
Controls formatting of floating point data Arguments:
  padding_width
The number of empty spaces between a column's edge and its content
  left_padding_width
The number of empty spaces between a column's left edge and its content
  right_padding_width
The number of empty spaces between a column's right edge and its content
  vertical_char
The charcter used when printing table borders to draw vertical lines
  horizontal_char
The charcter used when printing table borders to draw horizontal lines
  junction_char
The charcter used when printing table borders to draw line junctions
  format
Controls whether or not HTML tables are formatted to match styling options
  print_empty
Controls whether or not empty tables produce a header and frame or just an empty string
  attributes
A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML

Inherited from object: __class__

Method Details [hide private]

__init__(self, field_names=None, **kwargs)
(Constructor)

source code 

Return a new PrettyTable instance

Arguments:

encoding - Unicode encoding scheme used to decode any encoded input field_names - list or tuple of field names fields - list or tuple of field names to include in displays start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) header - print a header showing field names (True or False) header_style - stylisation to apply to field names in header ("cap", "title", "upper", "lower" or None) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: FRAME, HEADER, ALL, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data vertical_char - single character string used to draw vertical lines horizontal_char - single character string used to draw horizontal lines junction_char - single character string used to draw line junctions sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting valign - default valign for each row (None, "t", "m" or "b") reversesort - True or False to sort in descending or ascending order

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

_get_fields(self)

source code 

List or tuple of field names to include in displays

Arguments:

fields - list or tuple of field names to include in displays

_get_start(self)

source code 

Start index of the range of rows to print

Arguments:

start - index of first data row to include in output

_get_end(self)

source code 

End index of the range of rows to print

Arguments:

end - index of last data row to include in output PLUS ONE (list slice style)

_get_sortby(self)

source code 

Name of field by which to sort rows

Arguments:

sortby - field name to sort by

_get_reversesort(self)

source code 

Controls direction of sorting (ascending vs descending)

Arguments:

reveresort - set to True to sort by descending order, or False to sort by ascending order

_get_sort_key(self)

source code 

Sorting key function, applied to data points before sorting

Arguments:

sort_key - a function which takes one argument and returns something to be sorted

_get_header(self)

source code 

Controls printing of table header with field names

Arguments:

header - print a header showing field names (True or False)

_get_header_style(self)

source code 

Controls stylisation applied to field names in header

Arguments:

header_style - stylisation to apply to field names in header ("cap", "title", "upper", "lower" or None)

_get_border(self)

source code 

Controls printing of border around table

Arguments:

border - print a border around the table (True or False)

_get_hrules(self)

source code 

Controls printing of horizontal rules after rows

Arguments:

hrules - horizontal rules style. Allowed values: FRAME, ALL, HEADER, NONE

_get_vrules(self)

source code 

Controls printing of vertical rules between columns

Arguments:

vrules - vertical rules style. Allowed values: FRAME, ALL, NONE

_get_int_format(self)

source code 

Controls formatting of integer data Arguments:

int_format - integer format string

_get_float_format(self)

source code 

Controls formatting of floating point data Arguments:

float_format - floating point format string

_get_padding_width(self)

source code 

The number of empty spaces between a column's edge and its content

Arguments:

padding_width - number of spaces, must be a positive integer

_get_left_padding_width(self)

source code 

The number of empty spaces between a column's left edge and its content

Arguments:

left_padding - number of spaces, must be a positive integer

_get_right_padding_width(self)

source code 

The number of empty spaces between a column's right edge and its content

Arguments:

right_padding - number of spaces, must be a positive integer

_get_vertical_char(self)

source code 

The charcter used when printing table borders to draw vertical lines

Arguments:

vertical_char - single character string used to draw vertical lines

_get_horizontal_char(self)

source code 

The charcter used when printing table borders to draw horizontal lines

Arguments:

horizontal_char - single character string used to draw horizontal lines

_get_junction_char(self)

source code 

The charcter used when printing table borders to draw line junctions

Arguments:

junction_char - single character string used to draw line junctions

_get_format(self)

source code 

Controls whether or not HTML tables are formatted to match styling options

Arguments:

format - True or False

_get_print_empty(self)

source code 

Controls whether or not empty tables produce a header and frame or just an empty string

Arguments:

print_empty - True or False

_get_attributes(self)

source code 

A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML

Arguments:

attributes - dictionary of attributes

add_row(self, row)

source code 

Add a row to the table

Arguments:

row - row of data, should be a list with as many elements as the table has fields

del_row(self, row_index)

source code 

Delete a row to the table

Arguments:

row_index - The index of the row you want to delete. Indexing starts at 0.

add_column(self, fieldname, column, align='c', valign='t')

source code 

Add a column to the table.

Arguments:

fieldname - name of the field to contain the new column of data column - column of data, should be a list with as many elements as the table has rows align - desired alignment for this column - "l" for left, "c" for centre and "r" for right valign - desired vertical alignment for new columns - "t" for top, "m" for middle and "b" for bottom

_get_rows(self, options)

source code 

Return only those data rows that should be printed, based on slicing and sorting.

Arguments:

options - dictionary of option settings.

get_string(self, **kwargs)

source code 

Return string representation of table in current state.

Arguments:

start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) fields - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data vertical_char - single character string used to draw vertical lines horizontal_char - single character string used to draw horizontal lines junction_char - single character string used to draw line junctions sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting reversesort - True or False to sort in descending or ascending order print empty - if True, stringify just the header for an empty table, if False return an empty string

get_html_string(self, **kwargs)

source code 

Return string representation of HTML formatted version of table in current state.

Arguments:

start - index of first data row to include in output end - index of last data row to include in output PLUS ONE (list slice style) fields - names of fields (columns) to include header - print a header showing field names (True or False) border - print a border around the table (True or False) hrules - controls printing of horizontal rules after rows. Allowed values: ALL, FRAME, HEADER, NONE vrules - controls printing of vertical rules between columns. Allowed values: FRAME, ALL, NONE int_format - controls formatting of integer data float_format - controls formatting of floating point data padding_width - number of spaces on either side of column data (only used if left and right paddings are None) left_padding_width - number of spaces on left hand side of column data right_padding_width - number of spaces on right hand side of column data sortby - name of field to sort rows by sort_key - sorting key function, applied to data points before sorting attributes - dictionary of name/value pairs to include as HTML attributes in the <table> tag xhtml - print <br/> tags if True, <br> tags if false


Property Details [hide private]

field_names

Get Method:
_get_field_names(self)
Set Method:
_set_field_names(self, val)

align

Get Method:
_get_align(self)
Set Method:
_set_align(self, val)

valign

Get Method:
_get_valign(self)
Set Method:
_set_valign(self, val)

max_width

Get Method:
_get_max_width(self)
Set Method:
_set_max_width(self, val)

fields

List or tuple of field names to include in displays

Arguments:

fields - list or tuple of field names to include in displays

Get Method:
_get_fields(self) - List or tuple of field names to include in displays
Set Method:
_set_fields(self, val)

start

Start index of the range of rows to print

Arguments:

start - index of first data row to include in output

Get Method:
_get_start(self) - Start index of the range of rows to print
Set Method:
_set_start(self, val)

end

End index of the range of rows to print

Arguments:

end - index of last data row to include in output PLUS ONE (list slice style)

Get Method:
_get_end(self) - End index of the range of rows to print
Set Method:
_set_end(self, val)

sortby

Name of field by which to sort rows

Arguments:

sortby - field name to sort by

Get Method:
_get_sortby(self) - Name of field by which to sort rows
Set Method:
_set_sortby(self, val)

reversesort

Controls direction of sorting (ascending vs descending)

Arguments:

reveresort - set to True to sort by descending order, or False to sort by ascending order

Get Method:
_get_reversesort(self) - Controls direction of sorting (ascending vs descending)
Set Method:
_set_reversesort(self, val)

sort_key

Sorting key function, applied to data points before sorting

Arguments:

sort_key - a function which takes one argument and returns something to be sorted

Get Method:
_get_sort_key(self) - Sorting key function, applied to data points before sorting
Set Method:
_set_sort_key(self, val)

header

Controls printing of table header with field names

Arguments:

header - print a header showing field names (True or False)

Get Method:
_get_header(self) - Controls printing of table header with field names
Set Method:
_set_header(self, val)

header_style

Controls stylisation applied to field names in header

Arguments:

header_style - stylisation to apply to field names in header ("cap", "title", "upper", "lower" or None)

Get Method:
_get_header_style(self) - Controls stylisation applied to field names in header
Set Method:
_set_header_style(self, val)

border

Controls printing of border around table

Arguments:

border - print a border around the table (True or False)

Get Method:
_get_border(self) - Controls printing of border around table
Set Method:
_set_border(self, val)

hrules

Controls printing of horizontal rules after rows

Arguments:

hrules - horizontal rules style. Allowed values: FRAME, ALL, HEADER, NONE

Get Method:
_get_hrules(self) - Controls printing of horizontal rules after rows
Set Method:
_set_hrules(self, val)

vrules

Controls printing of vertical rules between columns

Arguments:

vrules - vertical rules style. Allowed values: FRAME, ALL, NONE

Get Method:
_get_vrules(self) - Controls printing of vertical rules between columns
Set Method:
_set_vrules(self, val)

int_format

Controls formatting of integer data Arguments:

int_format - integer format string

Get Method:
_get_int_format(self) - Controls formatting of integer data Arguments:
Set Method:
_set_int_format(self, val)

float_format

Controls formatting of floating point data Arguments:

float_format - floating point format string

Get Method:
_get_float_format(self) - Controls formatting of floating point data Arguments:
Set Method:
_set_float_format(self, val)

padding_width

The number of empty spaces between a column's edge and its content

Arguments:

padding_width - number of spaces, must be a positive integer

Get Method:
_get_padding_width(self) - The number of empty spaces between a column's edge and its content
Set Method:
_set_padding_width(self, val)

left_padding_width

The number of empty spaces between a column's left edge and its content

Arguments:

left_padding - number of spaces, must be a positive integer

Get Method:
_get_left_padding_width(self) - The number of empty spaces between a column's left edge and its content
Set Method:
_set_left_padding_width(self, val)

right_padding_width

The number of empty spaces between a column's right edge and its content

Arguments:

right_padding - number of spaces, must be a positive integer

Get Method:
_get_right_padding_width(self) - The number of empty spaces between a column's right edge and its content
Set Method:
_set_right_padding_width(self, val)

vertical_char

The charcter used when printing table borders to draw vertical lines

Arguments:

vertical_char - single character string used to draw vertical lines

Get Method:
_get_vertical_char(self) - The charcter used when printing table borders to draw vertical lines
Set Method:
_set_vertical_char(self, val)

horizontal_char

The charcter used when printing table borders to draw horizontal lines

Arguments:

horizontal_char - single character string used to draw horizontal lines

Get Method:
_get_horizontal_char(self) - The charcter used when printing table borders to draw horizontal lines
Set Method:
_set_horizontal_char(self, val)

junction_char

The charcter used when printing table borders to draw line junctions

Arguments:

junction_char - single character string used to draw line junctions

Get Method:
_get_junction_char(self) - The charcter used when printing table borders to draw line junctions
Set Method:
_set_junction_char(self, val)

format

Controls whether or not HTML tables are formatted to match styling options

Arguments:

format - True or False

Get Method:
_get_format(self) - Controls whether or not HTML tables are formatted to match styling options
Set Method:
_set_format(self, val)

print_empty

Controls whether or not empty tables produce a header and frame or just an empty string

Arguments:

print_empty - True or False

Get Method:
_get_print_empty(self) - Controls whether or not empty tables produce a header and frame or just an empty string
Set Method:
_set_print_empty(self, val)

attributes

A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML

Arguments:

attributes - dictionary of attributes

Get Method:
_get_attributes(self) - A dictionary of HTML attribute name/value pairs to be included in the <table> tag when printing HTML
Set Method:
_set_attributes(self, val)