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.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

TerminalWriter-1.0.1-py3-none-any.whl (5.9 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