Skip to content

Commit

Permalink
fix: fix error when integer value is in cell
Browse files Browse the repository at this point in the history
  • Loading branch information
enjoeyland committed Aug 20, 2024
1 parent a799902 commit 97f81eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/draw_shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def draw(self, slide: Slide, left: float=0, top: float=0):
self.drawed_shape = p
return p

def set_text(self, text: str): # TODO: 되는지 확인 필요
def set_text(self, text: str):
if self.drawed_shape is None:
raise ValueError("Shape is not drawn yet")
self.drawed_shape.runs[0].text = text
Expand Down
15 changes: 10 additions & 5 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def read_excel_data(filename):
assert len(data) > 0, "No data found in the excel file"
assert len(data) > 1, "Only header found in the excel file. No data found"
for i, row in enumerate(data):
data[i] = tuple(c if c is not None else "" for c in row)
data[i] = tuple(str(c) if c is not None else "" for c in row)

header = data[0]
header = [h.strip().lower() for h in header]
Expand All @@ -38,15 +38,20 @@ def headed_data_with_sample_num(header, data):
try:
sample_num_idx = header.index("sample num")
except:
sample_num_idx = len(header)
header += ("sample num",)
data = [d + (0,) for d in data]
else:
for i, d in enumerate(data):
d = list(d)
if d[sample_num_idx]:
d[sample_num_idx] = int(d[sample_num_idx])
else:
data[i] = tuple(d)
if isinstance(d[sample_num_idx], str):
if d[sample_num_idx].strip() == "":
continue
try:
d[sample_num_idx] = int(d[sample_num_idx].strip())
except:
raise ValueError(f"Sample number '{d[sample_num_idx]}' is not an integer in row {i+2}")
data[i] = tuple(d)
data = tuples_to_dict_list(header, data)
return data

Expand Down

0 comments on commit 97f81eb

Please sign in to comment.