Skip to content

Allow any stringifiable object in table values #22

Closed
@DenverCoder1

Description

@DenverCoder1

Allow table2ascii to convert objects such as numbers to strings when building table

text = t2a(
    header=[1, "G", "H", "R", "S"],
    body=[[1, 2, 3, 4, 5]],
    first_col_heading=True,
)

Error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jonah/.local/lib/python3.9/site-packages/table2ascii/table_to_ascii.py", line 309, in table2ascii
  File "/home/jonah/.local/lib/python3.9/site-packages/table2ascii/table_to_ascii.py", line 44, in __init__
  File "/home/jonah/.local/lib/python3.9/site-packages/table2ascii/table_to_ascii.py", line 102, in __auto_column_widths
  File "/home/jonah/.local/lib/python3.9/site-packages/table2ascii/table_to_ascii.py", line 98, in <lambda>
TypeError: object of type 'int' has no len()
        for i in range(self.__columns):
            # number of characters in column of i of header, each body row, and footer
>           header_size = len(self.__header[i]) if self.__header else 0
E           TypeError: object of type 'int' has no len()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions