Add numeric interval fields
This commit is contained in:
@@ -32,6 +32,17 @@ def normalize_interval(value):
|
||||
return re.sub(r"\s+", " ", value.replace("VÔO", "VOO")).strip()
|
||||
|
||||
|
||||
def interval_number(intervalo):
|
||||
if not intervalo:
|
||||
return ""
|
||||
first_token = intervalo.split()[0]
|
||||
if ":" in first_token:
|
||||
return int(first_token.split(":", 1)[0])
|
||||
if first_token.isdigit():
|
||||
return int(first_token)
|
||||
return ""
|
||||
|
||||
|
||||
def parse_control_fields(tokens):
|
||||
nivel_descricao = {
|
||||
"B": "Base",
|
||||
@@ -192,8 +203,11 @@ def parse_record(record):
|
||||
"duracao_unidade": control_fields["duracao_unidade"],
|
||||
"controle_original": controle,
|
||||
"intervalo_horas_voo": intervalo_horas_voo,
|
||||
"intervalo_horas_voo_valor": interval_number(intervalo_horas_voo),
|
||||
"intervalo_meses_continuos": intervalo_meses_continuos,
|
||||
"intervalo_meses_continuos_valor": interval_number(intervalo_meses_continuos),
|
||||
"intervalo_pousos": intervalo_pousos,
|
||||
"intervalo_pousos_valor": interval_number(intervalo_pousos),
|
||||
"intervalos": intervalos,
|
||||
"linha_original": record,
|
||||
}
|
||||
@@ -227,8 +241,11 @@ def main():
|
||||
"duracao_unidade",
|
||||
"controle_original",
|
||||
"intervalo_horas_voo",
|
||||
"intervalo_horas_voo_valor",
|
||||
"intervalo_meses_continuos",
|
||||
"intervalo_meses_continuos_valor",
|
||||
"intervalo_pousos",
|
||||
"intervalo_pousos_valor",
|
||||
"intervalos",
|
||||
]
|
||||
with CSV_PATH.open("w", newline="", encoding="utf-8-sig") as csv_file:
|
||||
|
||||
Reference in New Issue
Block a user