0

when i put in my code i am getting a row along the top that i do not know how to get rid of

this is the code:

import prettytable

def front_end():
    # Create a new table
    table = prettytable.PrettyTable()

    # Add the rows of the array to the table
    for row in array:
        table.add_row(row)

    # Set the alignment of the elements to center
    table.align = "c"

    # Set the border characters of the table
    table.border = True
    table.hrules = prettytable.ALL
    table.vrules = prettytable.ALL

    # Print the table
    print(table)

this is its output:

+---------+---------+---------+---------+---------+---------+---------+
| Field 1 | Field 2 | Field 3 | Field 4 | Field 5 | Field 6 | Field 7 |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   0.0   |   0.0   |   2.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   0.0   |   0.0   |   1.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   0.0   |   0.0   |   2.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   1.0   |   0.0   |   1.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   2.0   |   0.0   |   2.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   1.0   |   0.0   |   1.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+

this is what i would like:

+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   0.0   |   0.0   |   2.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   0.0   |   0.0   |   1.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   0.0   |   0.0   |   2.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   1.0   |   0.0   |   1.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   2.0   |   0.0   |   2.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+
|   0.0   |   1.0   |   0.0   |   1.0   |   0.0   |   0.0   |   0.0   |
+---------+---------+---------+---------+---------+---------+---------+

I have never used prettytable before so maybe there is a easy solution but i don't know it.

  • 1
    try : `print(table.get_string(header=False))`. Link: https://stackoverflow.com/questions/74839364/removing-the-column-headings-off-my-prettytable-table – Immature trader Dec 22 '22 at 16:03

0 Answers0