Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

terminaltables will fail if one of the table_data is of integer type #18

@xrogaan

Description

@xrogaan

Since terminaltables relies on the fact that all data present in the table_data list to be of string type, it will try to execute string operations on each of them. However, sometimes, people just want to print some integer or float data.

A good practice would be to sanitize the data, and turn it all to string before doing any operation. Or only do such operations on string data.

Traceback (most recent call last):
  File "main.py", line 208, in <module>
    cm.from_input(uInput, sInput)
  File "main.py", line 180, in from_input
    print(table.table)
  File "C:\Python27\lib\site-packages\terminaltables\base_table.py", line 126, in table
    padded_table_data = self.padded_table_data
  File "C:\Python27\lib\site-packages\terminaltables\base_table.py", line 113, in padded_table_
data
    widths = self.column_widths
  File "C:\Python27\lib\site-packages\terminaltables\base_table.py", line 92, in column_widths
    return column_widths(self.table_data)
  File "C:\Python27\lib\site-packages\terminaltables\width_and_alignment.py", line 93, in colum
n_widths
    widths[i] = max(widths[i], string_width(max(row[i].splitlines(), key=len)))
AttributeError: 'int' object has no attribute 'splitlines'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions