I am using texttable to print a table, but the data I want to print just happens to have some strings which look a bit like numbers. How do I stop texttable from interpreting those as floating points? I didn't pass them as floating points, so it is bizarre behaviour. I tried prepending spaces but it seems anything that can parse as a float counts as a float.
#!/bin/env python3.9
import texttable
table = texttable.Texttable()
table.add_rows([["Name", "Age", "Nickname"], ["Mr\nXavier\nHuon", 32, "Xav'"],
["Mr\nBaptiste\nClement", 1, "Baby"],
["Mme\nLouise\nBourgeau", "999994840", "Lou\n\nLoue"]])
print(table.draw() + "\n")
prints:
+----------+-----------+----------+
| Name | Age | Nickname |
+==========+===========+==========+
| Mr | 32 | Xav' |
| Xavier | | |
| Huon | | |
+----------+-----------+----------+
| Mr | 1 | Baby |
| Baptiste | | |
| Clement | | |
+----------+-----------+----------+
| Mme | 1.000e+09 | Lou |
| Louise | | |
| Bourgeau | | Loue |
+----------+-----------+----------+
but should print:
+----------+-----------+----------+
| Name | Age | Nickname |
+==========+===========+==========+
| Mr | 32 | Xav' |
| Xavier | | |
| Huon | | |
+----------+-----------+----------+
| Mr | 1 | Baby |
| Baptiste | | |
| Clement | | |
+----------+-----------+----------+
| Mme | 999994840 | Lou |
| Louise | | |
| Bourgeau | | Loue |
+----------+-----------+----------+