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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: TableAPI-1.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 61a02e191611f11b437ddecd4a17391685c1366a59289774c3047baec067521a
MD5 4fbe890c9416ef9b7d9c134f46a32e6e
BLAKE2b-256 5cf947cee4314c54575fc431f448ca021e5aac16b9b1c38c69faefeec3968e03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: TableAPI-1.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7affcf5297b1dde9c635d5bc442215f9a3a329f82082f69ccc43b4a04f5ca231
MD5 b6a83115e1f1819625ba221c577238d2
BLAKE2b-256 a0e5e066e1aba95e2141c9a995b4e0f7ad591897f442b45d81f27ee55a1a51b6

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