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

TypeError: can only concatenate str (not "NoneType") to str #36

Open
brianjmurrell opened this issue Jun 1, 2024 · 2 comments
Open

Comments

@brianjmurrell
Copy link

Trying to read an .ods file I am hitting:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel/core.py", line 47, in get_book
    book_stream = sources.get_book_stream(**keywords)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel/internal/core.py", line 38, in get_book_stream
    sheets = a_source.get_data()
             ^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel/plugins/sources/file_input.py", line 38, in get_data
    sheets = self.__parser.parse_file(self.__file_name, **self._keywords)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel/plugins/parsers/excel.py", line 19, in parse_file
    return self._parse_any(file_name, **keywords)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel/plugins/parsers/excel.py", line 40, in _parse_any
    sheets = get_data(anything, file_type=file_type, **keywords)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_io/io.py", line 86, in get_data
    data, _ = _get_data(
              ^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_io/io.py", line 105, in _get_data
    return load_data(**keywords)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_io/io.py", line 208, in load_data
    result[key] = list(result[key])
                  ^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_io/sheet.py", line 68, in to_array
    for column_index, cell_value in enumerate(
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_io/reader.py", line 126, in column_iterator
    yield from self._native_sheet.column_iterator(row)
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_ods3/odsr.py", line 35, in column_iterator
    yield self.cell_value(row, column)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/brian/.local/lib/python3.12/site-packages/pyexcel_ods3/odsr.py", line 46, in cell_value
    ret = str(cell_value) + " " + cell.currency
          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str

Is this project just too out of date to handle modern/current ODS files?

@brianjmurrell
Copy link
Author

I hacked around it with:

-            ret = str(cell_value) + " " + cell.currency
+            try:
+                ret = str(cell_value) + " " + cell.currency
+            except:
+                ret = str(cell_value)

But that is surely not the correct fix though.

mleiseca added a commit to mleiseca/pyexcel-ods3 that referenced this issue Jul 10, 2024
```
File "pyexcel_ods3/odsr.py", line 46, in cell_value
    ret = str(cell_value) + " " + cell.currency
          ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
TypeError: can only concatenate str (not "NoneType") to str
```
@mleiseca
Copy link
Contributor

I've created a PR with a fix: #37

@chfw Would you mind taking a look?

chfw added a commit that referenced this issue Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants