roskakori / cutplace

validate data stored in CSV, PRN, ODS or Excel files
http://cutplace.readthedocs.org/
GNU Lesser General Public License v3.0
18 stars 20 forks source link

Add Excel-CID reader for data format #63

Closed heubi95 closed 9 years ago

heubi95 commented 9 years ago

Add Excel-CID reader for data format

Goal: data formats stored in Excels files can be read to a CID. Rows starting with an empty row are skipped. Other rows raise an error.

roskakori commented 9 years ago

Cleanup code and improve testability by:

    def test_can_read_excel(self):
        cid_reader = cid.Cid()
        cid_path = dev_test.getTestIcdPath("icd_customers.xls")
        cid_reader.read(cid_path, _tools.excel_rows(cid_path))
        ...
    def test_fails_on_empty_data_format_property_name(self):
        cid_reader = cid.Cid()
        cid_reader.read('inline', [
            ['d', 'format', 'delimited'],
            ['d', '', ''],
        ])
        self.assertFails(...)

    def test_fails_on_missing_data_format_value_name(self):
        cid_reader = cid.Cid()
        cid_reader.read('inline', [
            ['d', 'format', 'delimited'],
            ['d', 'header'],
        ])
        self.assertFails(...)

    def test_fails_on_missing_data_format_property_name(self):
        cid_reader = cid.Cid()
        cid_reader.read('inline', [
            ['d', 'format', 'delimited'],
            ['d'],
        ])
        self.assertFails(...)
        for row in rows:
            if row != []:
                row_type = row[0].lower()
                row_data = (row[1:] + [''] * 7)[:7]
                if row_type == 'd':
                   ...
roskakori commented 9 years ago

_tools.excel_rows() needs a parameter sheet=1 to specify the sheet to use. Note that for xlrd the first sheet has the index 0.

roskakori commented 9 years ago

Opps, closed accidentally.

roskakori commented 9 years ago

It appears that this ticket is done. Can we close it?