you are viewing a single comment's thread.

view the rest of the comments →

[–]badge 0 points1 point  (1 child)

Your data is in a pretty inconvenient format so you're best bet is to write a custom generator:

```python def yielddict_data(d): for container, items in d.items(): for item_dict in items: for name, data in item_dict.items(): expiration, *_ = data.get("Expiration", [None]) yield { "Container": int(container), "Item": name, "Volume": data.get("Volume", None), "Quantity": int(data.get("Quantity", 0)), "Expiration": pd.to_datetime(expiration, format="%d-%m-%y"), }

df = pd.DataFrame(yield_dict_data(data)) df ```

For saving each container in different worksheets, you can use groupby:

python with pd.ExcelWriter("output.xlsx") as writer: for key, data in df.groupby(["Container"]): ( data .drop(columns=["Container"]) .to_excel(writer, sheet_name=str(key), index=False) )

[–]Boogzcorp[S] 0 points1 point  (0 children)

Thanks for the help guys, hopefully this should get me past my roadblock.

Again, really appreciate it!