From c735ec0ce3dce23eca2e15f824f899c3a0f7804c Mon Sep 17 00:00:00 2001 From: Blallo Date: Thu, 25 Aug 2022 21:35:37 +0200 Subject: [PATCH] Improve serializing --- devloop/serialize.py | 6 ++++++ latecomers/serializer.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/devloop/serialize.py b/devloop/serialize.py index 74ae9e5..da2a5d1 100644 --- a/devloop/serialize.py +++ b/devloop/serialize.py @@ -1,6 +1,8 @@ # -*- encoding: utf-8 -*- import os +import pandas as pd + from latecomers.parse import find_table, get_details from latecomers.serializer import to_excel @@ -14,3 +16,7 @@ for f in flights: data.append(get_details(f, os.environ.get("DEBUG") is not None)) print(to_excel(data)) + +colonne = {"th_arrival": "Arrivo teorico", "real_arrival": "Arrivo reale", + "code": "Codice volo", "origin": "Aeroporto di partenza", "status": "Stato"} +df = pd.DataFrame(data, columns=colonne) diff --git a/latecomers/serializer.py b/latecomers/serializer.py index 8a25587..ac0372f 100644 --- a/latecomers/serializer.py +++ b/latecomers/serializer.py @@ -27,6 +27,8 @@ def to_excel(data: T.List[Details]) -> bytes: "status": "Stato", } df = pd.DataFrame(data, columns=mapping) + df["status"] = df["status"].map(lambda x: x.value) + df.set_index("th_arrival", inplace=True) with NamedTemporaryFile() as tmp: df.to_excel(tmp)