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.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

TableAPI-1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: TableAPI-1.1.tar.gz
  • Upload date:
  • Size: 4.3 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.tar.gz
Algorithm Hash digest
SHA256 5464b625adfe19c3deac33dc81209b178ff1e1e7442cb2130ac8b9c3ab00b361
MD5 b9d95c70f2041c83bb4d97484c351e04
BLAKE2b-256 da8e2fcad5ec366261c95c5933d3b7bd9103f6e28aad84a7539b9bda995d6efa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: TableAPI-1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 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-py3-none-any.whl
Algorithm Hash digest
SHA256 55276e930a2b9d00a753de641c9b5ed38b980c03712e933c50f99965fd366388
MD5 1d35a7605fae5814ef84ce7cdfde9cb8
BLAKE2b-256 5af7fabd680f4df5d46b5b89eeb1e23b7a5dad0ecb378cf18acde478a1ab4bfe

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