Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when access formula with None stored #59

Closed
Spectre5 opened this issue Oct 27, 2021 · 2 comments
Closed

Error when access formula with None stored #59

Spectre5 opened this issue Oct 27, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Spectre5
Copy link

Spectre5 commented Oct 27, 2021

Pylightxl Version: 1.58
Python Version: 3.7

Summary of Bug/Feature: When using sheet.row with output='f', I get the traceback shown below. I've printed the sheet._data dictionary and it does in fact have None for some of the formulas. It is an array formula that I see it.

Traceback:

Traceback (most recent call last):
  File "testing.py", line 285, in test_read
    result = read_pylightxl(path)
  File "testing.py", line 158, in read_with_pylightxl
    page.append(sheet.row(row, output=output))
  File "<snip>\site-packages\pylightxl\pylightxl.py", line 1796, in row
    val = self.index(row, c, output=output)
  File "<snip>\site-packages\pylightxl\pylightxl.py", line 1733, in index
    return self.address(address, output=output)
  File "<snip>\site-packages\pylightxl\pylightxl.py", line 1656, in address
    rv = '=' + self._data[address]['f']
TypeError: can only concatenate str (not "NoneType") to str

Suggestion for fix (Option 1): Fix the immediate issue only

Change this

rv = '=' + self._data[address]['f']

to:

                rv = '=' + self._data[address]['f'] or ''

Suggestion for fix (Option 2): Avoid None earlier in the code for values, formulas, and comments

Change this

data.update({cell_address: {'v': cell_val, 'f': cell_formula, 's': '', 'c': comment}})

to:

        data.update({cell_address: {'v': cell_val or '', 'f': cell_formula or '', 's': '', 'c': comment or ''}})
@PydPiper PydPiper self-assigned this Oct 28, 2021
@PydPiper PydPiper added the bug Something isn't working label Oct 28, 2021
@PydPiper
Copy link
Owner

Hi @Spectre5 thank you for considering using pylightxl. It does in deed look like a bug, let me address it this week and ill get back to you. Thanks for submitting this!

PydPiper added a commit that referenced this issue Nov 2, 2021
@PydPiper
Copy link
Owner

PydPiper commented Nov 2, 2021

Hi @Spectre5, thank you for submitting this comprehensive issue. It was really easy to go back and make the changes. I have updated the master, but will hold off on releasing a new version till we get a more more improvements in.

@PydPiper PydPiper closed this as completed Nov 2, 2021
PydPiper added a commit that referenced this issue Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants