Skip to main content

This module has functions to generate simple tabular reports.

Project description

=====================
Terminal Reporter
=====================
-----
About
-----
Terminal Reporter is a lightweight console report formatting tool for tabular data. It can either write to a file or to the terminal (via stdout).

-----
Getting Started
-----
Importing the module:
>>> import TerminalWriter
Creating a title:

>>> import TerminalWriter
Creating a title:

>>> import writer
Creating a title:
>>> print(writer.title_generator("Sample Title", 10))
======================
Sample Title
======================
Creating the layout for the columns, in this case both columns have a width of 10:
>>> writer.column_generator([10, 10])
'{: <10}{: <10}\n'
Also use the column_generator with format to create a column header:
>>> writer.column_generator([10, 10]).format("column1", "column2")
'column1 column2 \n'
Generating a report is using a combination of the functions mentioned about and a list of lists:
>>> data = [["hello", "world"],
... ["goodbye", "world"]]
>>> report = writer.generate_report(writer.title_generator("hello world", 20),
... writer.column_generator([10, 10]).format("col1", "col2"),
... writer.column_generator([10, 10]),
... data)
>>> print(report)
===============================
hello world
===============================
col1 col2
=====================

hello world
goodbye world

If you want to save a report to disk, specify file_name for the display_report or leave it set to None (the default) to write it out to the console:
>>> writer.display_report(report, file_name=None)
===============================
hello world
===============================
col1 col2
=====================

hello world
goodbye world

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
TerminalWriter-1.0.1-py3-none-any.whl (5.9 kB) Copy SHA256 hash SHA256 Wheel py3 Dec 23, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page