1
donnees_meteo/scripts/fill_formatted_1s.py
2025-11-17 02:00:28 +01:00

33 lines
1.0 KiB
Python

# scripts/fill_formatted_1s.py
from __future__ import annotations
from pathlib import Path
from meteo.dataset import load_raw_csv, fill_missing_with_previous
INPUT_CSV_PATH = Path("data/weather_formatted_1s.csv")
OUTPUT_CSV_PATH = Path("data/weather_filled_1s.csv")
def main() -> None:
if not INPUT_CSV_PATH.exists():
print(f"⚠ Fichier introuvable : {INPUT_CSV_PATH}")
print(" Lancez d'abord : python -m scripts.format_raw_csv")
return
df_1s = load_raw_csv(INPUT_CSV_PATH)
print(f"Fichier 1s formaté chargé : {INPUT_CSV_PATH}")
print(f" Lignes : {len(df_1s)}, colonnes : {list(df_1s.columns)}")
df_filled = fill_missing_with_previous(df_1s)
print(f"Après propagation des dernières valeurs connues : {len(df_filled)} lignes")
OUTPUT_CSV_PATH.parent.mkdir(parents=True, exist_ok=True)
df_filled.to_csv(OUTPUT_CSV_PATH, index_label="time")
print(f"✔ Fichier 1s 'complet' écrit dans : {OUTPUT_CSV_PATH.resolve()}")
if __name__ == "__main__":
main()