Skip to main content

A package to form and retrieve tabular data

Project description

tabulux

This package is for performing tablular operations and for making making tabular data.

Download this documetation

This module requires 'pyperclip', for using the copy-paste feature You can still use this module without pyperclip, but it is strongly recommended to install pyperclip

visit PyPI-Pyperclip

Import using:

import tabulux

Create a table object using the table class

syntax:

table_obj = tabulux.table(   
    {   
    'Head-A':['Content-A1','Content-A2',],   
    'Head-B':['Content-B1','Content-B2',],   
    }   
)   

Now the table object have been saved to 'table_obj'

A Virtul table of the above object can be imagined like this:

| Head-A      | Head-B      |
|-------------+-------------|
| Content-A1  | Content-B1  |
| Content-A2  | Content-B2  |

Available functions and methods:

  • column_length() - returns the column length
  • row_length() - returns the row length
  • heads() - returns the all the headings of the table as a list of strings
  • head() - returns the heading of the specified column as a string
  • cell() - returns the content of a specified cell
  • display() - prints the data in the table in a tabulated form
  • row() - returns a specific row from the table as a list of string
  • column() - returns a specific column from the table as a list of string
  • change() - use this to change the content of a cell after the creation of the table
  • add() returns the sum of two cell content
  • add_all() - returns the sum of a series of cells
  • html() - returns the html code of the table

column_length()

Use this method when you need the column length of the table

Syntax:

table_obj.column_length(copy={True/False})

where:

  • table_obj = a table object
  • copy = This boolean attribute copies the result as text to your clipboard (False by default)

returns integer representing the number of column in table_obj

row_length()

Use this method when you need the number of rows of the table

Syntax:

table_obj.row_length(copy={True/False})

where:

  • table_obj = a table object
  • copy = This boolean attribute copies the result as text to your clipboard (False by default)

returns integer representing the number of rows in table_obj

column()

You could use the column() method to get a list containing all the elements in the specified column as a list

Syntax:

table_obj.column(column_number)

where:

  • table_obj = a table object
  • column_number = an integer which represents column number (starting from 0) or, the heading of the column (as a string)

returns all the elements from the specified column as list of strings. The column headings are not returned

A CellOutOfBoundsException is raised if the specified column exceeds the number of columns in the table

row()

You can use the row() method to get all the elements in a specified row in the table as a list

Syntax:

table_obj.row(row_number)

where:

  • table_obj = a table object
  • row_number = an integer representing the row number (starts from 0)

returns all the elements from the specified row as list of strings.

A CellOutOfBoundsException is raised if the specified row exceeds the number of rows in the table

heads()

Use heads() when you want all the headings of the table

Syntax :

table_obj.heads()

where:

  • table_obj = a table object

returns a list of string representing the each heading of the table

head()

Use head() when you want a heading of a specific column from the table

Syntax:

table_obj.head(column_number, copy={True/False})

where:

  • table_obj = A table object
  • column_number = An integer representing the column number, whose heading you want
  • copy = A boolean- if True, copies the heading to your clipboard(False by default)

returns the heading of the specified column of the table as a string.

cell()

Syntax:

Use this method when you need the cell content of a cell

table_obj.cell(row_ID, column_ID, copy={True/False})

where,

  • table_obj = table object
  • row = integer representing the row number (starting from 0), or, the heading of the column as a string
  • column = integer representing the column number (starting from 0)
  • copy = a boolean, if true- copies the result to your clipboard(False,by default)

returns the Cell Content of the specified location as String.

If the cell is not defined in the table or the rows or column given is out of bounds, a CellOutOfBoundsException is raised

display()

Use this method when you need to print the table in the console

Syntax :

table_obj.display()

where:

  • table_obj = a table object

Output: prints data in table_obj in a tabular form Here is how the table would be printed:

|Head-A |  Head-B | 
-------------------
|content-A1 | Content-B1 | 
|content-A2 | Content-B2 | 

This method does not return anything

change()

Use change() method to change the content of a cell

Syntax:

table_obj.change(row_ID, column_ID, new_content)

where,

  • table_obj = a table object
  • row_ID = an integer representing the column number(starts from 0)
  • column_ID = an integer representing the column number(starts from 0), or the heading of the column as a string
  • new_content = a string containg the new content

changes the of the specified column to the content in new_content

you can also set a cell content to whatever text copied to your clipboard, by setting the 'paste' argument to True

Syntax:

table_obj.change(row_ID, column_ID, new_content, paste=True)

the 'new_content' is ignored if paste is set to True, so you can leave the new content as "". This changes the cell in the specified location to the text in the clipboard.

Aditionaly, this method also returns the old content of the specified cell

add()

The add method can be used to add two cells, if the cells are integers or can be converted to integers,

Syntax:

table_obj.add(row1, column1, row2, column2, copy={True/False})

where:

  • table_obj = a table object
  • row1 = cell row of the first cell as an integer
  • column1 = cell column of the first cell as an integer, or the heading of the column as a string
  • row2 = cell row of the second cell as an integer
  • column2 = cell column of the second cell as an integer, or the heading of the column as a string
  • copy = If this boolean attribute is set to True, the result will be copied to your clipboard(False by default)

returns the sum of the two cells

add_all()

The add_all() method can be used to add all the cells from a cell to another cell, if all their values are integers

Syntax:

table_obj.add_all(from_row, from_column, to_row, to_column, copy={True/False})

where:

  • table_obj = a table object
  • from_row = row number of the first cell
  • from_column = column number of the first cell
  • to_row = row number of the last cell
  • to_column = column number of the last cell
  • copy = a boolean, if True- the result will be copied to your clipboard (False by default)

returns the sum of all the content of cells between the specified cells.

If any cell content cannot be converted to an integer, 'TypeError' is raised

NOTE: The the ending cell address(to_row, to_column) is not included in the sum.

html()

The 'html()' method is used to get the html snippet of a table.

Syntax:

table_obj.html(display={True/False}, copy={True/False}, indent={int})

where:

  • table_obj = a table object
  • display = if set to True, this boolean attribute will display the html snippet in the console\terminal, (False by default)
  • copy = this boolean attribute, if set to True, copies the html snippet to you clipboard, and can by pasted to your html file(False by default)
  • indent = indentation spaces that sould be applied, as integer (4 by default)

returns the html snippet of the table as a string, from and including <table> to </table>

Take me to this project's github repository page

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

tabulux-1.2.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

tabulux-1.2.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file tabulux-1.2.0.tar.gz.

File metadata

  • Download URL: tabulux-1.2.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.6

File hashes

Hashes for tabulux-1.2.0.tar.gz
Algorithm Hash digest
SHA256 40da6deb79eb7281edb34c8b94745b580dd61d1510bb85c519917454e0c83d4b
MD5 b839b2c9fc5490eb5cf2e2ff25d2a6ca
BLAKE2b-256 474563c79d650f05b49be5a824362457a0da4671bc761dcf3a71b0f2c4296cba

See more details on using hashes here.

File details

Details for the file tabulux-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: tabulux-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.6.6

File hashes

Hashes for tabulux-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4bf0f28f06efb5ca500c945c5db2596da2011a7604ab26d6b0f0c7a50e8f11b6
MD5 b9e0f6b416c5a5e2de997f960a798ebf
BLAKE2b-256 d6b46e0f9ee098530b40af5a2017d3711094e5168df16a5b755b3e0260050c4c

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