Package: basictable
basictableSmall library to print structured data in tablesLicenseMITInstallationpip3installbasictableData FormatThe recordset format is a list of dictionaries where the dictionary keys are the column headings. All the
records are required to have the same number of columns and same heading values (keys)[{'Col1':data1,'Col2':data2,'Col3':data2,'Col4':'data4'},{'Col1':data1,'Col2':data2,'Col3':data2,'Col4':'data4'},{'Col1':data1,'Col2':data2,'Col3':data2,'Col4':'data4'},{'Col1':data1,'Col2':data2,'Col3':data2,'Col4':'data4'},]Usage>>>frombasictableimportprint_table
>>>data=[]>>>foriinrange(20):
...data.append({'Col1':1,'Col2':"test",'Col3':'test test','Col4':'some longer string'})...
>>>print_table(data)Col3Col4Col1Col2-----------------------------------testtestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1test>>>print_table(data,border=True)|------------------------------------------------------||Col3|Col4|Col1|Col2||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||-------------+----------------------+--------+--------||testtest|somelongerstring|1|test||------------------------------------------------------|>>>print_table(data,headings_justify='left')Col3Col4Col1Col2-----------------------------------testtestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1test>>>print_table(data,headings_justify='left',order=('Col4','Col3','Col2','Col1'))Col4Col3Col2Col1-----------------------------------somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1somelongerstringtesttesttest1>>>print_table(data,data_justify='center',order=('Col1',))Col1Col2Col4Col3-----------------------------------1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest1testsomelongerstringtesttest>>>print_table(data,data_justify='center',order=('Col1','Col2','Col3'))Col1Col2Col3Col4-----------------------------------1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring1testtesttestsomelongerstring
>>>print_table(data,data_justify='center',border=True,order=('Col1','Col2','Col3'))|------------------------------------------------------||Col1|Col2|Col3|Col4||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||--------+--------+-------------+----------------------||1|test|testtest|somelongerstring||------------------------------------------------------|>>>print_table(data,data_justify='center',border=True,order=('Col1','Col2','Col3'),padding=8)|------------------------------------------------------------------------------------------------------||Col1|Col2|Col3|Col4||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||--------------------+--------------------+-------------------------+----------------------------------||1|test|testtest|somelongerstring||------------------------------------------------------------------------------------------------------|>>>print_table(data,border=True,records_per_page=3)|------------------------------------------------------||Col1|Col3|Col2|Col4||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------|[pressanykey]|1|testtest|test|somelongerstring||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------|[pressanykey]|1|testtest|test|somelongerstring||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------||1|testtest|test|somelongerstring||--------+-------------+--------+----------------------|[pressanykey]|1|testtest|test|somelongerstring||------------------------------------------------------|