Module for creating tables for console applications
Project description
PythonTableConsole
Simple console-oriented handler for python two-dimensional lists (tables). Put your list in handler, modify it and use it from handler or take it out from handler and use on its own.
Features:
- List handler that works with python 2-dimensional lists.
- Easy access to height and width of the table.
- Simple handy functions: transposing and sorting.
- Print your lists as tables to the console!
Examples:
Creating table from list:
import PythonTableConsole as PTC
my_list = [['a', 'b', 'c'], [1, 2, 3], [7,4,3,2,0,10]]
Table = PTC.PythonTableConsole(my_list)
# or PTC.PythonTableConsole([['a', 'b', 'c'], [1, 2, 3], [7,4,3,2,0,10]])
Printing table to the console:
print(Table)
'''
result:
|a|1| 7|
|b|2| 4|
|c|3| 3|
| | | 2|
| | | 0|
| | |10|
'''
Changing table:
Table.contains[0][0] = 'alpha'
Functions of the PythonTableConsole class:
Table.width() # returns number of columns
Table.height() # returns number of rows
Table.transpose() # transposes the Table: rows to columns, columns to rows
Table.sort_by_column(column_index, skip_n_rows = 0) # sorts the table (except first n rows) by specified column. MAY BE REMOVED IN THE FUTURE
Table.sort_by_column_with_skips(column_index, skip_rows = [], skip_columns = [], largest_at_the_top = True) # sorts the table (except specified rows and columns) by the specified column.
Table.sort_by_row_with_skips(row_index, skip_rows = [], skip_columns = [], largest_at_the_top = True) # sorts the table (except specified rows and columns) by the specified row.
Other, uh... important? notes:
Columns not rows
PythonTableConsole handles inner lists as columns.
pos_x, pos_y = 0, 0
Table.contains[pos_x][pos_y] # not [pos_y][pos_x]
Row-centered handler may be implemented in the future. But for now you can transpose your tables to compensate for that handler absense.
Updates are completely random
This is a pet-project so...
Planned features:
Row-centered handler
For now only column-centered is present in this module.
Width constrains for str
- Default max width for table's columns
- Max width for table's columns
- Max widths (in list, idk) dor table's columns
- "New line or cut" option (maybe with "cut after n new_lines" option)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file PythonTaCo-1.3.7.tar.gz.
File metadata
- Download URL: PythonTaCo-1.3.7.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b21bec55204148bf897ef77caccb675ab24dc47ae2a8335c8132e7f5510807f7
|
|
| MD5 |
dbe9ce7aa94ba006dd3f9c522ef03b13
|
|
| BLAKE2b-256 |
ff3fb60b96e19fb5afd93a5e5bba37f55c8544d4ba6211b68a2ed93818b8fc33
|
File details
Details for the file PythonTaCo-1.3.7-py3-none-any.whl.
File metadata
- Download URL: PythonTaCo-1.3.7-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c801bb432f26fcbb6c3bd56b475213506abcfd17c3dc3b7b24f5b87c246a8ffa
|
|
| MD5 |
b62fdb7741fab81b29a7ffc457bf9ffd
|
|
| BLAKE2b-256 |
e13e0aa56d1fbcf210ae2206844107aed9a186d72b6f6e8945604ad5a9bc101e
|