Ash
Ash

Reputation: 1

How to set fixed column width in tabulate module of python

How to set fixed column width in tabulate module of python

eg:

table_header = ['CURRENT TIME', 'NAMESPACE', 'CPU REQUESTS', 'CPU LIMITS', 'MEMORY REQUESTS', 'MEMORY LIMITS']
with open("abc.txt", 'a') as txt_file:
    txt_file.write(tabulate([table_header], headers='firstrow', tablefmt='grid', stralign=('center', 'center', 'center', 'center', 'center', 'center')) + '\n')

The header and the data are not aligned properly due to difference in column width.

Upvotes: 0

Views: 589

Answers (0)

Related Questions