With this code:
from prettytable import PrettyTable
x= PrettyTable()
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
x.add_row(["Adelaide", 1295, 1158259, 600.5])
print(x)
Prints the next:
+-----------+------+------------+-----------------+
| City name | Area | Population | Annual Rainfall |
+-----------+------+------------+-----------------+
| Adelaide | 1295 | 1158259 | 600.5 |
+-----------+------+------------+-----------------+
And what I want is to add one more column so it looks like this(I did it in excel just for illustration):
I tried to add a row with only that value:
from prettytable import PrettyTable
x= PrettyTable()
x.field_names = ["City name", "Area", "Population", "Annual Rainfall"]
x.add_row(["Adelaide", 1295, 1158259, 600.5])
x.add_row(["City No. 1"])
print(x)
But I get an error:
edu@DESKTOP-0VFHRDP MINGW64 ~/Documents/tables (master)
$ C:/Users/edu/AppData/Local/Programs/Python/Python38-32/python.exe c:/Users/edu/Documents/tables/test.py
Traceback (most recent call last):
File "c:/Users/edu/Documents/tables/test.py", line 5, in <module>
x.add_row(["City No. 1"])
File "C:\Users\edu\AppData\Local\Programs\Python\Python38-32\lib\site-packages\prettytable\prettytable.py", line 1037, in add_row
raise Exception(
Exception: Row has incorrect number of values, (actual) 1!=4 (expected)
If you have other idea to make it I am open for recomendations. Thanks by your help.