0

Every examples I saw the user knows the number and the names of columns. What if my field names are in a list or in a dictionary and I don't know the number of them?

I read that the right code would be:

t = PrettyTable()
t.set_field_names("first","second","third")

but in my case names are inside a dictionary named columns:

columns = {column0: "first", column1: "second", column3: "third"}

I remind the number of columns is unknown for me. I tried with:

for x in range(0,len(columns)):
    target="column"+str(x)
    t.set_field_names(columns[target])

or with a list:

columns = ["first","second","third"]
t = PrettyTable()
t.set_field_names(columns)

but everytime error is the same:

 File "time_based_blind.py", line 105, in <module>
    t.set_field_names(columns)
 File "/usr/lib/python2.7/dist-packages/prettytable.py", line 217, in __getattr__
    raise AttributeError(name)
AttributeError: set_field_names

1 Answers1

0

PrettyTable has no attribute set_field_names you might change that to columns = ["first","second","third"] t = PrettyTable(columns)