Skip to content

Commit

Permalink
bug fix writing data to excel
Browse files Browse the repository at this point in the history
  • Loading branch information
Jürgen Altszeimer committed Apr 29, 2020
1 parent a6c5084 commit 7f91c45
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions arxml_data_extractor/data_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def write_excel(self, file: str, data: dict, queries: List[DataObject]):

workbook.close()

def __write_worksheet(self, sheet, data: dict, query: DataObject):
def __write_worksheet(self, sheet, data: Union[dict, list], query: DataObject):
header = self.__extract_header(query)
if isinstance(data, dict):
data = [data]
df = self.__flatten(data)

start = self.__write_header(sheet, header)
Expand Down Expand Up @@ -122,10 +124,10 @@ def __flatten(cls, data: Union[list, dict]):
if isinstance(value, dict):
rows.extend(cls.__flatten(value))
elif isinstance(value, list):
row = rows.copy()
copy = rows.copy()
rows.clear()
for v in value:
rows.append(row + cls.__flatten(v))
rows.append(copy + cls.__flatten(v))
else:
rows.append(value)
elif isinstance(data, list):
Expand Down

0 comments on commit 7f91c45

Please sign in to comment.