Skip to content

Not able to handle decimal.Decimal #74

Description

@chfw
>>> from decimal import Decimal
>>> import pyexcel as p
>>> s=p.Sheet([[Decimal(11)]])
>>> s
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyexcel/sheets/sheet.py", line 557, in __repr__
    result = self.texttable
  File "pyexcel/sources/__init__.py", line 64, in custom_presenter
    memory_source.write_data(self)
  File "pyexcel/sources/file_source_output.py", line 78, in write_data
    sheet, **self._keywords)
  File "pyexcel/renderers/factory.py", line 48, in render_sheet_to_stream
    self.render_sheet(sheet, **keywords)
  File "pyexcel/renderers/_texttable.py", line 15, in render_sheet
    content = render_text_table(sheet, self._write_title)
  File "pyexcel/renderers/_texttable.py", line 34, in render_text_table
    table.add_row(list(_cleanse_a_row(data[0])))
  File "pyexcel/renderers/_texttable.py", line 47, in _cleanse_a_row
    yield(to_format(str, item))
  File "pyexcel/sheets/formatters.py", line 126, in to_format
    func = CONVERSION_FUNCTIONS[from_type]
KeyError: <class 'decimal.Decimal'>

reference: pyexcel-webwares/django-excel#32 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions