1. Sergey Astanin
  2. python-tabulate
Issue #1 resolved

None in data causes TypeError

Catherine Devlin
created an issue
>>> import tabulate
>>> tabulate.tabulate([[1, 'foo', 'some'], [2, 'bar', None]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/tabulate.py", line 423, in tabulate
  File "build/bdist.linux-x86_64/egg/tabulate.py", line 262, in _column_type
  File "build/bdist.linux-x86_64/egg/tabulate.py", line 148, in _type
  File "build/bdist.linux-x86_64/egg/tabulate.py", line 129, in _isnumber
  File "build/bdist.linux-x86_64/egg/tabulate.py", line 114, in _isconvertible
TypeError: float() argument must be a string or a number

Comments (4)

  1. Troy Zimmerman

    TypeError is also raised if you're trying to print a datetime object. I added in "except (TypeError, ValueError)" in the _isconvertible function, but perhaps there is a more graceful way to do this. Should I open a separate issue?

  2. Log in to comment