Skip to content

Commit 1952360

Browse files
Fix #N/A handling
1 parent 452d6a5 commit 1952360

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

pandas/io/excel/_odfreader.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List
22

3+
import numpy as np
34
from pandas._typing import FilePathOrBuffer, Scalar
45
from pandas.compat._optional import import_optional_dependency
56

@@ -149,10 +150,11 @@ def _is_empty_row(self, row) -> bool:
149150
def _get_cell_value(self, cell, convert_float: bool) -> Scalar:
150151
from odf.namespaces import OFFICENS
151152

152-
# print("cell: ", cell, convert_float)
153+
# print("\ncell: ", cell, convert_float)
154+
if str(cell) == "#N/A":
155+
return np.nan
153156

154157
cell_type = cell.attributes.get((OFFICENS, "value-type"))
155-
cell_value = cell.attributes.get((OFFICENS, "value"))
156158
# print("type=", cell_type, "value=", repr(cell_value))
157159
if cell_type == "boolean":
158160
if str(cell) == "TRUE":
@@ -162,16 +164,11 @@ def _get_cell_value(self, cell, convert_float: bool) -> Scalar:
162164
return self.empty_value
163165
elif cell_type == "float":
164166
# GH5394
165-
166-
value = cell.attributes.get((OFFICENS, "value"))
167-
if value == "": # NA handling
168-
return ""
169-
cell_value = float(cell_value)
167+
cell_value = float(cell.attributes.get((OFFICENS, "value")))
168+
# print("value = ", value)
170169
if convert_float:
171-
# print("convert", cell_value, int(cell_value))
172170
val = int(cell_value)
173171
if val == cell_value:
174-
# print("return the int")
175172
return val
176173
return cell_value
177174
elif cell_type == "percentage":

0 commit comments

Comments
 (0)