Improve serializing

This commit is contained in:
sfigato 2022-08-25 21:35:37 +02:00
parent 5182cdeb84
commit c735ec0ce3
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
2 changed files with 8 additions and 0 deletions

View File

@ -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)

View File

@ -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)