Skip to content

Commit

Permalink
Merge pull request #85 from LeComptoirDesPharmacies/main
Browse files Browse the repository at this point in the history
report main to develop
  • Loading branch information
thomas-lcdp authored Aug 14, 2024
2 parents 3a6612a + d514891 commit 6b13578
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions business/mappers/excel_lines_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def map_to_obj(self):
excel_path=self.excel_path,
excel_mapper=self.excel_mapper,
sheet_name=parameters.sheet_name,
header_row=parameters.header_line,
min_row=parameters.content_start_line,
header_row=int(parameters.header_line),
min_row=int(parameters.content_start_line),
obj_unique_key=self.unique_key,
custom_dict=ConditionalDict(
condition_func=self.condition,
Expand Down
8 changes: 7 additions & 1 deletion business/services/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ def excel_to_dict(obj_class, excel_path, excel_mapper, sheet_name, header_row,
column_indices = {col: cell.value for col, cell in enumerate(ws[header_row])}
for idx, row in enumerate(ws.iter_rows(min_row=min_row, max_row=max_row, values_only=True)):
obj = obj_class()
cells = {column_indices[col]: value for col, value in enumerate(row)}

cells = {
column_indices[col]: int(value) if isinstance(value, float) and value.is_integer() else value
for col, value in enumerate(row)
if value is not None
}

for col in excel_mapper:
col.set_from_excel(obj, cells.get(col.excel_column_name, None))
if obj_unique_key:
Expand Down

0 comments on commit 6b13578

Please sign in to comment.