Skip to main content

Print basic tables in python

Project description

tablat

A simple way to print output in a table

Basic usage

Just create a Table object and give it a headers list and the data. The number of columns will be calculated from the number of headers.

Installation

You can intall the package using pip (Python Package Installer)

pip install tablat

or

python -m pip install tablat

Code sample

Code

from pathlib import Path
from tablat import Table

folder_path = Path('./')
header = ['FILE_NAME', 'FOLDER', 'FILES_IN']
data = []

for file_path in folder_path.iterdir():
    data.append(file_path.name)
    if file_path.is_dir():
        data.extend(['YES', len([f for f in file_path.iterdir()])])

    else:
        data.extend(['NO', 0])

my_table = Table(data, header)
my_table.print_table()

Output

table_output

Notes

You can retrieve data form the table using indices

# Get first row data
my_table[0]

# Get third row, second column
my_table[2][1]

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

tablat-0.1.2.tar.gz (3.7 kB view hashes)

Uploaded Source

Built Distribution

tablat-0.1.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

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