petl-developers/petl

Support corrupted workbooks in xlrd

arturponinski opened this issue · 0 comments

Minimal, reproducible code sample, a copy-pastable example if possible

petl/test/io/test_xls.py

    def test_passing_kwargs_to_xlutils_view():
        filename = _get_test_xls()
        if filename is None:
            return

        from petl.io.xlutils_view import View
        org_init = View.__init__

        def wrapper(self, *args, **kwargs):
            assert "ignore_workbook_corruption" in kwargs
            return org_init(self, *args, **kwargs)

        with patch("petl.io.xlutils_view.View.__init__", wrapper):
            tbl = fromxls(filename, 'Sheet1', use_view=True, ignore_workbook_corruption=True)
            expect = (('foo', 'bar'),
                      ('A', 1),
                      ('B', 2),
                      ('C', 2),
                      (u'é', datetime(2012, 1, 1)))
            ieq(expect, tbl)
            ieq(expect, tbl)
assert "ignore_workbook_corruption" in kwargs
AssertionError

Problem description

Some xls generators of other vendors output xls workbooks marked as corrupt. In order to support such files, update of xlrd package to 2.0.1 is required, additionally fromxls with use_view=True does not pass kwargs to xlutils_view.View

Version and installation information

Value of petl.version 1.7.5.dev6+dirty
Version of Python interpreter, tests on all supported versions