Skip to content

Formula Parsing Error #160

@agoddijn

Description

@agoddijn

What actually happened

[Please include the full traceback if there was an exception]

Traceback (most recent call last):
File "/opt/homebrew/lib/python3.11/site-packages/pycel/excelformula.py", line 923, in eval_func
excel_formula.compiled_lambda())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/pycel/excelformula.py", line 948, in
### Traceback will show this line if not loaded from a text file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/pycel/lib/stats.py", line 203, in countif
valid = find_corresponding_index(rng, criteria)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/pycel/excelutil.py", line 1104, in find_corresponding_index
return tuple(find_corresponding_index_generator(rng, criteria))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/pycel/excelutil.py", line 1113, in
for c, item in enumerate(row) if check(item))
^^^^^^^^^^^
File "/opt/homebrew/lib/python3.11/site-packages/pycel/excelutil.py", line 1031, in
return lambda x: x is not None and compiled.match(x.lower()) is not None
^^^^^^^
AttributeError: 'int' object has no attribute 'lower'

What was expected to happen

If I cast x to string before calling lower, I get the right output

Problem description

[If needed, this should explain why the current behavior is a problem and why the expected output is a better solution]

Evaluation is failing when it shouldn't be

Code Sample

# Your code here
workbook = openpyxl.load_workbook(tmp_xlsx)
workbook_compiler = ExcelCompiler(excel=workbook)
workbook_compiler.evaluate(get_cell_coordinate(cell, sheet_name))

[If possible, include a minimal, complete, and verifiable example to help us identify the issue. This also helps check that the issue is not with your own code]

Environment

[Pycel Version, Python Version and OS used. Also any other environment details that you think might be relevant]

Python 3.11
Pycel 1.0b30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions