[Python] How to generate table using Python

Discussão em 'Python' iniciado por Stack, Março 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am quite struggling with as I tried many libraries to print table but no success - so I thought to post here and ask.

    My data is in a text file (resource.txt) which looks like this (the exact same way it prints)

    pipelined 8 8 0 17 0 0
    nonpipelined 2 2 0 10 0 0


    I want my data print in the following manner

    Design name LUT Lut as m Lut as I FF DSP BRAM
    -------------------------------------------------------------------
    pipelined 8 8 0 17 0 0
    Non piplined 2 2 0 10 0 0


    Some time data may be more line column remain same but rows may increase.

    (i have python 2.7 version)

    I am using this part in my python code all code working but am couldn't able print data which i extracted to text file in tabular form. As I can't use panda library as it won't support for python 2.7, but I can use tabulate and all library. Can anyone please help me?

    I tried using tabulate and all but I keep getting errors.

    I tried at end simple method to print but its not working (same code works if I put at top of code but at the end of code this won't work). Does anyone have any idea?

    q11=open( "resource.txt","r")
    for line in q11:
    print(line)

    Continue reading...

Compartilhe esta Página