Documentation

class tablebase.CsvTable(csv_path: str, divider: str = ',')

Used to import a CSV file.

Parameters
  • csv_path – The path to your CSV

  • divider – The divider between columns.

class tablebase.Table

The Table class is the basic table in tablebase.

add_col(col_name: str, default_value: Any = '', trim: bool = True) None

Used to add a column to your table.

Parameters
  • col_name – The name of your new column.

  • default_value – The default value for new records in that column or a list of specific values for this column.

  • trim – Boolean value to know whether to trim the default list value if longer than other columns

Returns

add_expand(new_col_name: str, formula: str) None

Used to add a column that is based on another column.

Parameters
  • new_col_name – The new name for your column.

  • formula – The formula (string) for your expand. Use @ signs to name your column names. For example "@col_name@". The return result will be in your result. You can use built-in python functions. Example: str(int(@col_name@) + 10) + @another_col_name@

Returns

add_row(new_content: Union[list, dict]) None

Used to add a row to your table.

Parameters

new_content – A list of the entries you wish to add. It can also be a dictionary with the key being the column name and the value being the content.

Returns

count() int

Used to find how many rows in the Table.

Returns

An integer value of the amount of rows.

del_col(col_name: str) None

Used to delete a column

Parameters

col_name – The name of the column you wish to delete

Returns

display(max_rows: int = 10) None

Use display for pretty-printing to the console.

Parameters

max_rows – How many rows to display.

Returns

edit_cell(row_num: int, col_name: str, new_value: Any) None

Used to edit a cell of your table.

Parameters
  • row_num – The row number of the record that you wish to edit.

  • col_name – The column name of your record that you wish to edit.

  • new_value – The new record value.

Returns

edit_row(row_num: int, new_value: Union[list, dict]) None

Used to edit a row.

Parameters
  • row_num – The row number to edit.

  • new_value – Use a list override a row. If you use a dictionary, the key will be the column name.

Returns

expand(col_name: str, formula: str) None

Used to override a column that is based on another column.

Parameters
  • col_name – The name of the column that you want to override.

  • formula – The formula (string) for your expand. Use @ signs to name your column names. For example "@col_name@". The return result will be in your result. You can use built-in python functions. Example: str(int(@col_name@) + 10) + @another_col_name@

Returns

filter(formula: str, search_start: int = 1, search_end: Union[str, int] = 'END') tablebase.Table

Used to filter your table.

Parameters
  • formula – The formula (string) for your filter. Use @ signs to name your column names. For example @col_name@. You can write your filter just like an if statement. Example: @col_name@ == 'hello' You can use built-in python functions. Example: float(@col_name@) + float(@another_col_name@) > 10

  • search_start – The row to start filtering at.

  • search_end – The row to stop filtering at. Type “END” to stop at the end.

Returns

A Table object with the filtered results.

get_col(col_name: str) list

Used to get all data in one column.

Parameters

col_name – The name of the column you wish to get.

Returns

A list of all data in one column (column name not included).

incorporate(new_table: tablebase.Table) None

Used to merge data from another table into the object applying the methood.

Parameters

new_table – The Table object to merge

Returns

legacy_filter(col_name: str, value: Any, filter_type: str = 'exact', search_start: int = 1, search_end: Union[str, int] = 'END', add_headers_to_result: bool = True, legacy: bool = False) Union[tablebase.Table, list]

Used to filter your table.

Parameters
  • col_name – The column you wish to use to filter.

  • value – The value you wish to use to filter with.

  • filter_type – The filter type. Can be “exact” (same), “iexact” (not case-sensitive), “greaterthan”, or “lessthan”.

  • search_start – The row to start filtering at.

  • search_end – The row to stop filtering at. Type “END” to stop at the end.

  • add_headers_to_result – If True, your table headers will be included in the result.

  • legacy – If True, will return a list instead of a Table object.

Returns

A Table object with the filtered results (unless specified otherwise).

override_col(col_name: str, value: list) None

Used to override all content in the column

Parameters
  • col_name – The name of the column

  • value – A list with your new column content.

Returns

rename_col(col_name: str, new_col_name: str) None

Used to rename a column.

Parameters
  • col_name – The current name of the column

  • new_col_name – The new name that you want to give your column

Returns

save(path: str, divider: str = ',') None

Used to save your table for that file.

Parameters
  • path – Path to that file.

  • divider – The divider between columns.

Returns

sort(col_name: str, ascending: bool = True) None

Used to sort the Table by a column

Parameters
  • col_name – The column name by which to filter.

  • ascending – Specifies if the Table should be sorting ascending or descending

Returns

table_content = [[]]

The table_content holds the table data

Note

.table_content returns a list of lists

tablebase.formula_setup(added_objects)

Add packages, modules, variables, functions, and other objects to be used in expand and filter formulas.

Parameters

added_objects – A list containing the objects you want to include

Returns