Skip to content

Commit 2e246fc

Browse files
committed
cleaner parsing
1 parent 56106ba commit 2e246fc

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

xldown/charts.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,17 @@ def _read_cell_range(workbook: Workbook, range_str: str) -> list:
5959
sheet_name = sheet_part.strip("'")
6060
try:
6161
ws = workbook[sheet_name]
62-
except KeyError:
63-
return []
64-
values: list = []
65-
try:
6662
cells = ws[cell_range]
67-
if not isinstance(cells, tuple):
68-
cells = (cells,)
69-
for row in cells:
70-
if not isinstance(row, tuple):
71-
row = (row,)
72-
for cell in row:
73-
if cell.value is not None:
74-
values.append(cell.value)
75-
except Exception:
76-
pass
63+
except (KeyError, Exception):
64+
return []
65+
66+
values = []
67+
rows = cells if isinstance(cells, tuple) else (cells,)
68+
for row in rows:
69+
cells_in_row = row if isinstance(row, tuple) else (row,)
70+
for cell in cells_in_row:
71+
if cell.value is not None:
72+
values.append(cell.value)
7773
return values
7874

7975

0 commit comments

Comments
 (0)