gemseo / third_party / prettytable

prettytable module

The pretty table core

Classes:

PrettyTable([field_names])

param encoding

Unicode encoding scheme used to decode any encoded input

class gemseo.third_party.prettytable.prettytable.PrettyTable(field_names=None, **kwargs)[source]

Bases: object

Parameters
  • encoding – Unicode encoding scheme used to decode any encoded input

  • title – optional table title

  • field_names

    list or tuple of field names

    By default it is set to None.

  • 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

  • header – print a header showing field names

  • header_style – stylisation to apply to field names in header

  • border – print a border around the table

  • hrules – controls printing of horizontal rules after rows

  • vrules – controls printing of vertical rules between columns

  • int_format – controls formatting of integer data

  • float_format – controls formatting of floating point data

  • min_table_width – minimum desired table width

  • max_table_width – maximum desired table width

  • padding_width – number of spaces on either side of column data

  • 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

  • valign – default valign for each row

  • reversesort – True or False to sort in descending or ascending order

  • oldsortslice – Slice rows before sorting in the

Methods:

add_column(fieldname, column[, align, valign])

Add a column to the table.

add_row(row)

Add a row to the table

clear()

Delete all rows and field names from the table, maintaining nothing but styling options

clear_rows()

Delete all rows from the table but keep the current field names

copy()

del_row(row_index)

Delete a row to the table

get_html_string(**kwargs)

param title

optional table title

get_string(**kwargs)

param title

optional table title

paginate([page_length])

param page_length

Default value = 58)

set_style(style)

param style

Attributes:

align

Controls alignment of fields

attributes

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

border

Controls printing of border around table

end

End index of the range of rows to print

field_names

List or tuple of field names

fields

List or tuple of field names to include in displays

float_format

Controls formatting of floating point data

format

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

header

Controls printing of table header with field names

header_style

Controls stylisation applied to field names in header

horizontal_char

The charcter used when printing table borders to draw horizontal lines

hrules

Controls printing of horizontal rules after rows

int_format

Controls formatting of integer data

junction_char

The charcter used when printing table borders to draw line junctions

left_padding_width

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

max_table_width

max_width

Controls maximum width of fields

min_table_width

min_width

Controls minimum width of fields

oldsortslice

oldsortslice - Slice rows before sorting in the 'old style'

padding_width

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

print_empty

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

reversesort

Controls direction of sorting (ascending vs descending)

right_padding_width

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

sort_key

Sorting key function, applied to data points before sorting

sortby

Name of field by which to sort rows

start

Start index of the range of rows to print

title

Optional table title

valign

Controls vertical alignment of fields

vertical_char

The charcter used when printing table borders to draw vertical lines

vrules

Controls printing of vertical rules between columns

add_column(fieldname, column, align='c', valign='t')[source]

Add a column to the table.

Parameters
  • fieldname – name of the field to contain the new column of data

  • column – column of data

  • table – has rows

  • align

    desired alignment for this column (Default value = “c”)

    By default it is set to c.

  • valign

    desired vertical alignment for new columns (Default value = “t”)

    By default it is set to t.

add_row(row)[source]

Add a row to the table

Parameters
  • row – row of data

  • has – fields

property align

Controls alignment of fields

Parameters

align – alignment

property attributes

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

Arguments:

attributes - dictionary of attributes

property border

Controls printing of border around table

Parameters

border – print a border around the table

clear()[source]

Delete all rows and field names from the table, maintaining nothing but styling options

clear_rows()[source]

Delete all rows from the table but keep the current field names

copy()[source]
del_row(row_index)[source]

Delete a row to the table

Parameters

row_index – The index of the row you want to delete

property end

End index of the range of rows to print

Parameters

end – index of last data row to include in output PLUS ONE

property field_names

List or tuple of field names

property fields

List or tuple of field names to include in displays

property float_format

Controls formatting of floating point data

Parameters

float_format – floating point format string

property format

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

Parameters

format – True or False

get_html_string(**kwargs)[source]
Parameters
  • title – optional table title

  • start – index of first data row to include in output

  • end – index of last data row to include in output PLUS ONE

  • fields – names of fields

  • header – print a header showing field names

  • border – print a border around the table

  • hrules – controls printing of horizontal rules after rows

  • vrules – controls printing of vertical rules between columns

  • 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

  • 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

  • attributes – dictionary of name

  • xhtml – print

get_string(**kwargs)[source]
Parameters
  • title – optional table title

  • start – index of first data row to include in output

  • end – index of last data row to include in output PLUS ONE

  • fields – names of fields

  • header – print a header showing field names

  • border – print a border around the table

  • hrules – controls printing of horizontal rules after rows

  • vrules – controls printing of vertical rules between columns

  • 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

  • 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

  • reversesort – True or False to sort in descending or ascending order

  • print – empty

property header

Controls printing of table header with field names

Parameters

header – print a header showing field names

property header_style

Controls stylisation applied to field names in header

Parameters

header_style – stylisation to apply to field names in header

property horizontal_char

The charcter used when printing table borders to draw horizontal lines

Parameters

horizontal_char – single character string used to draw horizontal lines

property hrules

Controls printing of horizontal rules after rows

Parameters

hrules – horizontal rules style

property int_format

Controls formatting of integer data

Parameters

int_format – integer format string

property junction_char

The charcter used when printing table borders to draw line junctions

Parameters

junction_char – single character string used to draw line junctions

property left_padding_width

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

Parameters

left_padding – number of spaces

property max_table_width
property max_width

Controls maximum width of fields

Parameters

max_width – maximum width integer

property min_table_width
property min_width

Controls minimum width of fields

Parameters

min_width – minimum width integer

property oldsortslice

oldsortslice - Slice rows before sorting in the ‘old style’

property padding_width

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

Parameters

padding_width – number of spaces

paginate(page_length=58, **kwargs)[source]
Parameters

page_length

Default value = 58)

By default it is set to 58.

property print_empty

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

Parameters

print_empty – True or False

property reversesort

Controls direction of sorting (ascending vs descending)

Parameters

reveresort – set to True to sort by descending order

property right_padding_width

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

Parameters

right_padding – number of spaces

set_style(style)[source]
Parameters

style

property sort_key

Sorting key function, applied to data points before sorting

Parameters

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

property sortby

Name of field by which to sort rows

Parameters

sortby – field name to sort by

property start

Start index of the range of rows to print

Parameters

start – index of first data row to include in output

property title

Optional table title

Parameters

title – table title

property valign

Controls vertical alignment of fields

Parameters

valign – vertical alignment

property vertical_char

The charcter used when printing table borders to draw vertical lines

Parameters

vertical_char – single character string used to draw vertical lines

property vrules

Controls printing of vertical rules between columns

Parameters

vrules – vertical rules style