TableLogger
TableLogger is a handy Python utility for logging tabular data into a console or a text file with little overhead.
Usage
from table_logger import TableLogger
tbl = TableLogger(columns='a,b,c,d')
tbl(1, 'Row1', datetime.now(), math.pi)
tbl(2, 'Row2', datetime.now(), 1/3)
tbl(3, 'Row3', datetime.now(), random.random())
Output:
+----------------------+----------------------+---------------------+----------------------+ | a | b | c | d | |----------------------+----------------------+---------------------+----------------------| | 1 | Row1 | 2015-12-28 21:13:46 | 3.141592653589793 | | 2 | Row2 | 2015-12-28 21:13:46 | 0.333333333333333 | | 3 | Row3 | 2015-12-28 21:13:46 | 0.854212894923849 |
Features
sane default formatting for basic python types
row number, timestamp and time delta columns
csv output
allows to adjust column width and format
python 2.7 and 3 support
Installation
PyPI:
$ pip install table-logger
GitHub:
$ git clone https://github.com/AleksTk/table-logger $ cd table-logger $ python setup.py install
Examples
Include row number, time-delta and timestamp columns
tbl = TableLogger(columns='data', rownum=True, time_delta=True, timestamp=True)
for e in 'abcde':
time.sleep(random.randint(0, 3))
tbl(e)
Output:
+-----------+----------------------------+-----------------+----------------------+ | row | timestamp | time delta | data | |-----------+----------------------------+-----------------+----------------------| | 1 | 2016-01-01 21:40:35.956815 | 0.000000000 | a | | 2 | 2016-01-01 21:40:35.957315 | 0.000000000 | b | | 3 | 2016-01-01 21:40:37.957569 | 2.000253916 | c | | 4 | 2016-01-01 21:40:37.957569 | 0.000500202 | d | | 5 | 2016-01-01 21:40:39.958323 | 2.000253916 | e |
Write to csv file
with open('log.csv', 'wb') as csvfile:
tbl = TableLogger(file=csvfile, csv=True, columns='a,b')
tbl('John "Smith"', 1200000.890)
tbl('Tommy,Cache', 70000.125)
Output:
a,b "John ""Smith""",1200000.890000 "Tommy,Cache",70000.125000
Specify custom column widths and formatters
tbl = TableLogger(columns='name,salary',
float_format='{:,.2f}'.format,
default_colwidth=15)
tbl('John Smith', 1200000.890)
tbl('Tommy Cache', 70000.125)
Output:
+-----------------+-----------------+ | name | salary | |-----------------+-----------------| | John Smith | 1,200,000.89 | | Tommy Cache | 70,000.12 |
Metadata
Release files for table-logger 0.3.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| table-logger-0.3.6.tar.gz | 6.6 kB | Without provenance | Details for table-logger-0.3.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| table_logger-0.3.6-py3-none-any.whl | Python 3 | none | any | Details for table_logger-0.3.6-py3-none-any.whl |
Total release size: 20.7 kB
Release files / table-logger-0.3.6.tar.gz
| Download URL | table-logger-0.3.6.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cd348ba7d9d167d0bd7fdb988cd2d1d3051b5a17236a7c50979678a82f0b4ca4
|
|
BLAKE2b-256 checksum How to use checksums |
7075f2892ac122cc36fecafdaa29e807470f3b27fc27a0e8c6d9507f018cf5ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.0
|
Release files / table_logger-0.3.6-py3-none-any.whl
| Download URL | table_logger-0.3.6-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dac0be8b20ea8ce6a9646bf68fb2f71218724fb4dbe3108a105641ca14bd167a
|
|
BLAKE2b-256 checksum How to use checksums |
0d80d4e0e9005caccae0185d4919844792a9227ebf4ed8e431c13625556b8c74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.0
|
Security for table-logger 0.3.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.