Skip to main content

Create a simple table c:

Project description

TableAPI

TableAPI is a very simple "API" to create tables in the python console. Its not much but i love this project lmao :)

Getting Started

To write a simple Table, create a table object with the columns and some simple rows:

table = Table('A', 'B')
table.add_row('This is', 'a simple test')

Now we have a table, but how do we render it in the console? Well, we have to print the build of the table. Very simple.

print(table.build())

In the console should be a simple table now.

Worst Documentation Ever

Create a Table

There are two ways to create a Table. First one, define the column titles directly in the constructor:

table = Table('A', 'B')

or define the amount of columns and have no titles:

table = Table(2) # Has to be bigger than 0

Build a Table

Simple, it will return a string, which you can print in the console

table = Table('A', 'B')
print(table.build()) # Table#Build() will return the table as a string

Here you go ;)


Define new Header

It is possible to define a new header with following code snippet:

table.set_header('A', 'B')

NOTE: The amount of strings must match with the amount of columns!


Add a Row

To add a row to a table just write:

table.add_row('A', 'B')

NOTE: The amount of strings must match with the amount of columns!


Remove a Row

To remove a row from a table just write:

table.remove_row(0) # 0 => Row Index

NOTE: Index must be smaller than row size and bigger than zero, else it will return None!


Get a Row Object

There is also a way to get the Row object out of the table. You can write:

table.get_row(0) # 0 => Row Index

NOTE: Index must be smaller than row size and bigger than zero, else it will return None!


Edit a Field

To Edit a Field of a table in a specific row and column, this snippet could help:

table.edit_field(0, 1)  # 0 => Row Index 
						# 1 => Column Index

NOTE: Row-Index must be smaller than the row size and bigger than zero! NOTE: Column-Index must be smaller than the column size and bigger than zero!


Exceptions

There are some exceptions that can come up and here is explained, how you can work with them

InvalidArgSizeException

This Exception will come up if the argument size is not matching a valid pattern. For Example, if you write

table = Table(2, 2)
# or
table = Table()

it will raise this exception, because you can only define 1 column integer or multiple strings. If the Constructor is empty, it doesnt work.


InvalidIndexException

This Exception will raise, if the Index on a function that doesnt return something, cannot find a specific Index like this:

table = Table(1)
table.get_row(200) # There is no row 200

The Exception just means, that the index isnt available.


FieldNotFoundException

This Exception will raise, if the field isnt available:

table = Table(1)
table.edit_field(69, 69) # There is no row 69 and column 69

The Exception just means, that the Field on the row-index and column-index isn't available.


Have fun coding <3
~fluffy

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

TableAPI-1.1.3.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

TableAPI-1.1.3-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file TableAPI-1.1.3.tar.gz.

File metadata

  • Download URL: TableAPI-1.1.3.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for TableAPI-1.1.3.tar.gz
Algorithm Hash digest
SHA256 66f6f504a5c671825d19681009a6ba2b559df33a1b17d8cc33f7505abb35e0c2
MD5 cb4481ea1a78af223663f8380957b578
BLAKE2b-256 c79a37079bf0d5f66a3009abc380e635a8e81d6289c6e571f24fe887b5db8146

See more details on using hashes here.

File details

Details for the file TableAPI-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: TableAPI-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for TableAPI-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b7e69847dcd9602624a3dc312c9c8a969173b47916835e2306003779e1f5f77e
MD5 5de193a66bd35873e5a285d877f9a028
BLAKE2b-256 c9b464e22770053f135963c168b0eeff2b0715bd9b1f5dccca14be3d07b1373b

See more details on using hashes here.

Supported by

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