I am using tabulate
to pretty-print tables in Python 2.7. It does align anything that can be converted to an number nicely by decimal point and also supports truncation of digits after the decimal point. However, I need both of these capabilities when working with number strings that contain a suffix (e.g. 37.58 MiB
).
import tabulate
fields = [['37.58 MiB', '42.2323 KiB'],
['0.12893 GiB', '8.012 MiB']]
print tabulate.tabulate(fields)
yields the output:
----------- ----------- 37.58 MiB 42.2323 KiB 0.12893 GiB 8.012 MiB ----------- -----------
what I want is this:
----------- ----------- 37.58 MiB 42.23 KiB 0.12 GiB 8.01 MiB ----------- -----------
Is tabulate
capable of achieving this?