Skip to main content

A Python lib that makes creating tables easier than ever !

Project description

Console Creator

A Python lib that makes creating tables easier than ever !

This lib enables you to create tables, and manipulate them from their columns and rows, instead of having to deal with the usual troubles of this process.

Install

Install from PyPI

To install this library, just type pip install python-tables-lib and this should be ok.

Visit PyPI for more info.

Install from source

Just download the file at this link, and import it in your project.

Usage

See examples if wanted.

This library provides the Table class, which is the table you are going to use.

Table init

This class has two optional parameters on creation :

  • name : A string containing the name of the table.
  • size : he size of the table. If not filled, the table will be flexible. Otherwise, the table will only fit this size. This should be a tuple of (rows, columns).

The add_row, add_rows, add_column, and add_columns methods

These methods will add rows or columns to the table.

They are disabled if the table size is fixed.

The add_row and add_column methods will take as argument a list or tuple, and will add all its elements to the table.

The add_rows and add_columns methods will take as argument a list/tuple of lists/tuples and will add all its elements to the table.

The delete_row and delete_column methods

The names are pretty explicit : The functions deletes the row/column of the given index

The return_row and return_column methods

These methods will return as list of lists the rows/columns of the table.

Example :

from tables import *

# Table creation
table = Table()
table.add_row([0, 1, 2])
table.add_row([0, 5, 0])

print(table.return_rows())
print(table.return_columns())

Outputs the following :

[[0, 1, 2], [0, 5, 0]]
[[0, 0], [1, 5], [2, 0]]

The render_table function

This method prints a stylized view of the table in the console.

Optional argument :

  • row_numbers_enabled : Boolean indicating whether or not to display the number of rows. True by default.

Example :

from tables import *

# Table creation
table = Table("Testing table")
table.add_row([0, 1, 2])
table.add_row([0, 5, 0])

# Stylized table print
table.render_table()

Outputs the following :

--- Testing table ---
0 -> | 0 | 1 | 2 | 
1 -> | 0 | 5 | 0 | 

The set_element method

This method sets the value of an element.

Arguments :

  • row : The row number.
  • column : The column number.
  • value : The value to insert in this cell.
  • name : The name of the cell (optional).

See the example at this link, with a Morpion game.

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

python_tables_lib-1.0.0.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_tables_lib-1.0.0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file python_tables_lib-1.0.0.tar.gz.

File metadata

  • Download URL: python_tables_lib-1.0.0.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for python_tables_lib-1.0.0.tar.gz
Algorithm Hash digest
SHA256 55298cc594a6b80156774753ed30fc4fb2fbe2162fd2962552b120a74e5fa47b
MD5 c7b4d263a92b3ba750242b07a09b29d5
BLAKE2b-256 b5cf4dc00e87b291879666c699ff122f47d7aad95c80d821e11b82776af4c445

See more details on using hashes here.

File details

Details for the file python_tables_lib-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: python_tables_lib-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2

File hashes

Hashes for python_tables_lib-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54cad15b279d05996ab55ee06c129af0cf05d67f41b46eb99b09a1496296e298
MD5 5c7106bf464439e2ce7efa193dbc66a0
BLAKE2b-256 01cdbf016e30593bc566966cd39209a9b1a1b93ea7131eb6bd6eacadc1f77940

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page