prettytable module¶
The pretty table core¶
- 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 (Sequence[str] | None) – 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
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
- add_column(fieldname, column, align='c', valign='t')[source]¶
Add a column to the table.
- Parameters:
fieldname (str) – name of the field to contain the new column of data
column – column of data
table – has rows
align (str) –
desired alignment for this column (Default value = “c”)
By default it is set to “c”.
valign (str) –
desired vertical alignment for new columns (Default value = “t”)
By default it is set to “t”.
- clear()[source]¶
Delete all rows and field names from the table, maintaining nothing but styling options
- Return type:
None
- clear_rows()[source]¶
Delete all rows from the table but keep the current field names
- Return type:
None
- del_row(row_index)[source]¶
Delete a row to the table
- Parameters:
row_index – The index of the row you want to delete
- 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
- paginate(page_length=58, **kwargs)[source]¶
- Parameters:
page_length (int) –
Default value = 58)
By default it is set to 58.
- 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
- 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
- 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
- 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
- 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