diff --git a/changelog.yml b/changelog.yml index 09c536a..fc7568c 100644 --- a/changelog.yml +++ b/changelog.yml @@ -1,6 +1,12 @@ name: pyexcel-ods3 organisation: pyexcel releases: +- changes: + - action: added + details: + - '`#36`: fixing get_data for a currency cell with no currency defined' + date: 10.7.2024 + version: 0.6.2 - changes: - action: added details: diff --git a/pyexcel_ods3/odsr.py b/pyexcel_ods3/odsr.py index 262d1ce..e0577cc 100644 --- a/pyexcel_ods3/odsr.py +++ b/pyexcel_ods3/odsr.py @@ -43,7 +43,10 @@ def cell_value(self, row, column): if service.has_no_digits_in_float(cell_value): cell_value = int(cell_value) - ret = str(cell_value) + " " + cell.currency + if cell.currency is None: + ret = str(cell_value) + else: + ret = str(cell_value) + " " + cell.currency elif cell_type in service.ODS_FORMAT_CONVERSION: value = cell.value n_value = service.VALUE_CONVERTERS[cell_type](value) diff --git a/tests/fixtures/currency_without_currency.ods b/tests/fixtures/currency_without_currency.ods new file mode 100644 index 0000000..c0e0b65 Binary files /dev/null and b/tests/fixtures/currency_without_currency.ods differ diff --git a/tests/test_bug_fixes.py b/tests/test_bug_fixes.py index aa69420..07ba468 100644 --- a/tests/test_bug_fixes.py +++ b/tests/test_bug_fixes.py @@ -109,5 +109,15 @@ def test_issue_30_precision_loss(): sheet.save_as(test_file) +def test_issue_36(): + from pyexcel_ods3 import get_data + + test_file = "currency_without_currency.ods" + data = get_data(get_fixtures(test_file)) + eq_(data["Sheet1"][6][0], '1.75"') + eq_(data["Sheet1"][6][5], "95") + eq_(data["Sheet1"][6][6], 25) + + def get_fixtures(filename): return os.path.join("tests", "fixtures", filename)