Closed heubi95 closed 9 years ago
Cleanup code and improve testability by:
cid.excel_rows()
to _tools
and get rid of unused self
parameter.Cid.read(self, sourcepath)
to Cid.read(self, source_path, rows)
test_cid.Cidtest
to test_cid.CidTest
test_cid.CidTest.test_can_read_excel_and_create_dataformat
to: 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(...)
Cid.read
, e.g.: for row in rows:
if row != []:
row_type = row[0].lower()
row_data = (row[1:] + [''] * 7)[:7]
if row_type == 'd':
...
_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.
Opps, closed accidentally.
It appears that this ticket is done. Can we close it?
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.