finesse.utilities.tables.Table
¶
Overview
- class finesse.utilities.tables.Table(table, headerrow=True, headercolumn=False, color=(-1, -1, -1), backgroundcolor=(-1, -1, -1), alignment='left', compact=False)[source]¶
Bases:
object
Basic class to display tables via pretty printing or html.
This class is a container object for formatted tables. All entries should either be strings or have a __str__ method with readable output. The table can be pretty printed for console and displayed as html. Additionally the table can be saved to a csv file using the same syntax as the csv package or rendered as latex code.
- Parameters:
- tablearray or list
A two dimensional array or list-of-lists containing strings.
- headerrowbool, default=True
Whether the first row is a header.
- headercolumnbool, default=False
Whether the first column is a header.
- colorarray, optional
An array with shape table.shape + (3,) of type int containing RGB color data to control the textcolor. If any value in a RGB triple is negative, no color will be applied to the corresponding cell.
- backgroundcolorarray, optional
An array to set the backgroundcolors of the cells, works like color.
- alignmentarray, optional
An array with on of (“left”, “center”, “right) for each cell.
- compactboolean, optional
Skip internal row separators to save space when printing as string.
Notes
Instead of arrays, color, backgroundcolor and alignment can be given only one option per row, column or total. This will be expanded for the whole table.
Methods
|
|
|
Add the color codes to the string if necessary. |
|
Replace special characters in latex with their latex representation. |
|
Expand a string to have a certain length. |
Create the whole table. |
|
|
Generate html code for the table cell at position (row, column). |
|
Create the `i`th row with the given elements. |
|
Generate the string separating two rows. |
Determine the maximum width of an entry in this column and add 2. |
|
|
Get the visible length of the string. |
Make latex code that produces the table. |
|
Define the colors used in the table for latex. |
|
|
Create latex code for the cell at position (row, column). |
Show the table. |
|
|
Write the table data to a csv file using the csv package. |