lazy_table - a python-tabulate wrapper for producing tables from generators

Overview

lazy_table

A python-tabulate wrapper for producing tables from generators.

Motivation

lazy_table is useful when (i) each row of your table is generated by a possibly expensive computation and (ii) you want to print rows to the screen as soon as they are available.

For example, the rows in the table below correspond to numerically solving an ordinary differential equation with progressively more steps. See examples/euler_vdp.py for the code to generate this table.

Here is the same example with a progress bar.

Installation and usage

Install lazy_table via pip:

$ pip install lazy_table

In your Python code, add

import lazy_table as lt

Now, generating your own lazy table is as simple as calling lt.stream on a generator that yields one or more lists, where each list is a row of your table (see the example below).

Example

As a toy example, consider printing the first 10 Fibonacci numbers in a table. Since this is a relatively cheap operation, we will pretend it is expensive by adding an artificial sleep(1) call beteween Fibonacci numbers.

import time
import lazy_table as lt

def fib_table(n):
     x0, x1 = 0, 1
     yield [0, x0]
     yield [1, x1]
     for i in range(2, n + 1):
         time.sleep(1)  # Simulate work
         x0, x1 = x1, x0 + x1
         yield [i, x1]

lt.stream(fib_table(10), headers=['N', 'F_N'])

Your final table should look like this:

  N    F_N
---  -----
  0      0
  1      1
  2      1
  3      2
  4      3
  5      5
  6      8
  7     13
  8     21
  9     34
 10     55

You can also specify an "artist" that determines how the table is rendered. For example, the ConsoleWithProgress artist displays a progress bar alongside the table indicating the percentage of rows completed:

n_rows = 10
artist = lt.artists.ConsoleWithProgress()
lt.stream(fib_table(n_rows), headers=['N', 'F_N'], n_rows=n_rows, artist=artist)
You might also like...
cli simple python script to interact with iphone afc api based on python library( tidevice )
cli simple python script to interact with iphone afc api based on python library( tidevice )

afcclient cli simple python script to interact with iphone afc api based on python library( tidevice ) installation pip3 install -U tidevice cp afccli

Python command line tool and python engine to label table fields and fields in data files.

Python command line tool and python engine to label table fields and fields in data files. It could help to find meaningful data in your tables and data files or to find Personal identifable information (PII).

xonsh is a Python-powered, cross-platform, Unix-gazing shell
xonsh is a Python-powered, cross-platform, Unix-gazing shell

xonsh is a Python-powered, cross-platform, Unix-gazing shell language and command prompt.

A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

Dead simple CLI tool to try Python packages - It's never been easier! :package:
Dead simple CLI tool to try Python packages - It's never been easier! :package:

try - It's never been easier to try Python packages try is an easy-to-use cli tool to try out Python packages. Features Install specific package versi

Python commandline tool for remembering linux/terminal commands
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

A Telegram Bot Written In Python To Upload Medias To telegra.ph

Telegraph-Uploader A Telegram Bot Written In Python To Upload Medias To telegra.ph DEPLOY YOU CAN SIMPLY DEPLOY ON HEROKU BY CLICKING THE BUTTON BELOW

Rich is a Python library for rich text and beautiful formatting in the terminal.
Rich is a Python library for rich text and beautiful formatting in the terminal.

The Rich API makes it easy to add color and style to terminal output. Rich can also render pretty tables, progress bars, markdown, syntax highlighted source code, tracebacks, and more — out of the box.

Comments
  • status bar stays on screen after using ConsoleWithProgress

    status bar stays on screen after using ConsoleWithProgress

    If you stream a table with ConsoleWithProgress, it works great. But I have more output to display after the table but the 100% progress bar is stuck somehow on the bottom of the screen.

    example

    lazy_table.stream(...artist=lazy_table.artists.ConsoleWithProgress()) print("Hello world!") # this line will be above the status bar.

    I think after the table is printed the cursor is positioned before the status bar and it inserts any additional output before the status bar.

    Is there a way to remove the status bar when complete?

    opened by amm042 2
  • Remove tqdm

    Remove tqdm

    Removes tqdm as a dependency in lieu of a custom progress bar and solves issue #2 in the process.

      Steps      Value          Delta       Order
    -------  ---------  -------------  ----------
        200   0.785109  nan            nan
        400  -0.131546   -0.916655     nan
        800  -0.723048   -0.591502       0.631995
       1600  -1.02156    -0.298515       0.986578
       3200  -1.16159    -0.140028       1.09209
       6400  -1.22794    -0.0663467      1.07762
      12800  -1.26004    -0.0321066      1.04715
      25600  -1.27581    -0.0157701      1.02568
      51200  -1.28363    -0.00781233     1.01337
     102400  -1.28751    -0.00388776     1.00681
     204800  -1.28945    -0.00193925     1.00344
     409600  -1.29042    -0.000968464    1.00173
    
    |████████████████████████████████| 12/12 [6.22s, 1.93it/s]
    
    opened by parsiad 0
Releases(v0.2.1)
Command line tool to automate transforming the effects of one color profile to another, possibly more standard one.

Finished rendering the frames of that animation, and now the colors look washed out and ugly? This terminal program will solve exactly that.

Eric Xue 1 Jan 26, 2022
Custom function scheduler TUI (text-based user interface) in the console

Custom function scheduler TUI (text-based user interface) in the console

Luke 1 Oct 26, 2022
pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery.

pypinfo: View PyPI download statistics with ease. pypinfo is a simple CLI to access PyPI download statistics via Google's BigQuery. Installation pypin

Ofek Lev 351 Dec 26, 2022
The most comprehensive, exhaustive, parameterized command-line wordle solver.

Wordle Solver The most comprehensive, exhaustive, parameterized command-line wordle solver. Wordle is a real

Debarghya Das 27 Nov 21, 2022
Convert markdown to HTML using the GitHub API and some additional tweaks with Python.

Convert markdown to HTML using the GitHub API and some additional tweaks with Python. Comes with full formula support and image compression.

phseiff 70 Dec 23, 2022
Python codecs extension featuring CLI tools for encoding/decoding anything

CodExt Encode/decode anything. This library extends the native codecs library (namely for adding new custom encodings and character mappings) and prov

Alex 210 Dec 30, 2022
A command line application to analyse reports from TBC Warcraft Logs.

README A command line application to analyse reports from TBC Warcraft Logs. The application was written and tested with Python 3.9. Features Dumps an

2 Dec 17, 2021
WazirX Portfolio Tracker on your Terminal!

If you have been investing in crypto in India, there is a very good chance that you are using WazirX. If you are using WazirX, then you definitely know that there is no P&L report, no green arrows no

Raunit 15 Jan 10, 2022
Cli tool to browse and play anime

browse and watch anime (scrape from gogoanime) (wip) basically ani-cli but in python cuz python good demo dependencies mpv installation from pypi pip

sheep padowo 2 Apr 20, 2022
Tmux Based Dropdown Dashboard For Python

sextans It's a private configuration and an ongoing experiment while I use Archlinux. A simple drop down dashboard based on tmux. It includes followin

秋葉 4 Dec 22, 2021
A powerful, colorful, beautiful command-line-interface for pypi.org

pypi-command-line pypi-command-line is a colorful, powerful, and beautiful command line interface for pypi.org that is actively maintained Detailed Do

Wasi Master 32 Jun 23, 2022
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

439 Jan 02, 2023
A command line tool made in Python for the popular rhythm game

osr!name A command line tool made in Python for the popular rhythm game "osu!" that changes the player name of a .osr file (replay file). Example: Not

2 Dec 28, 2021
liquidctl – liquid cooler control Cross-platform tool and drivers for liquid coolers and other devices

Cross-platform CLI and Python drivers for AIO liquid coolers and other devices

1.7k Jan 08, 2023
dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project

dbt-subdocs dbt-subdocs is a python CLI you can used to generate a dbt-docs for a subset of your dbt project 🤔 Description This project is useful if

Jambe 6 Jan 03, 2023
Python commandline tool for remembering linux/terminal commands

ehh Remember linux commands Commandline tool for remembering linux/terminal commands. It stores your favorite commands in ~/ehh.json in your homedir a

56 Nov 10, 2022
Python package with library and CLI tool for analyzing SeaFlow data

Seaflowpy A Python package for SeaFlow flow cytometer data. Table of Contents Install Read EVT/OPP/VCT Files Command-line Interface Configuration Inte

<a href=[email protected]"> 3 Nov 03, 2021
Package installer for python

This is a package that adds a JSON file to your project that records all of the packages used in it and allows people to install it with a single command.

Anmol Malik 1 May 23, 2022
Wordle-textual - Play Wordle from the CLI, using Textual

Wordle, playable from the CLI This project seeks to emulate Wordle in your shell

PhenoM4n4n 3 Mar 29, 2022
A useful and easy to use Terminal Timer made with Python.

Terminal SpeedCubeTimer Installation ¡No requirements! Just Download and play Usage Starts timer.py and you will see this. python timer.py Scramble

Achalogy 5 Dec 22, 2022