Python Library: termtables | Pretty tables in terminal

06 Sep 2022

Library resources
PyPI https://pypi.org/project/termtables/
Github https://github.com/nschloe/termtables

pip3 install termtables

Example

import termtables as tt

# define header row of pretty table with a list
header = ['email', 'first']

# empty list that will be populated and printed
list_to_print = []

# data
data = grist_xx.xxx.fetch_table('Master')

count_empty_first_name = 0

for contact in data:
    if contact.first == '':
        first = my_utils.first_from_email(contact.email)
        # appending the email and first name pairs as tuple to the list
        list_to_print.append((first, contact.email))

# pretty printing the table using the tuples in the list
tt.print(
list_to_print,
header=header,
style=tt.styles.markdown,
padding=(0, 1),
# alignment="lcr"
)

outputs:

output

links

social