Ajout données T2 législatives 2024

This commit is contained in:
Emmy D'Anello 2024-07-19 22:01:01 +02:00
parent 47cfdf705a
commit 645951823a
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 13 additions and 6 deletions

View File

@ -10,7 +10,8 @@ from nupes.models.legislatives2024 import *
def importer_resultats_bv(engine: Engine, verbose: bool = False) -> None: def importer_resultats_bv(engine: Engine, verbose: bool = False) -> None:
tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/6813fb28-7ec0-42ff-a528-2bc3d82d7dcd")] tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/6813fb28-7ec0-42ff-a528-2bc3d82d7dcd"),
(2, "https://www.data.gouv.fr/fr/datasets/r/ca974f04-cfd9-4da8-8554-4a868a09c6c2")]
with Session(engine) as session: with Session(engine) as session:
candidats = {(candidat.circonscription_id, candidat.numero): candidat candidats = {(candidat.circonscription_id, candidat.numero): candidat
@ -150,7 +151,8 @@ def importer_resultats_bv(engine: Engine, verbose: bool = False) -> None:
def importer_resultats_commune(engine: Engine, verbose: bool = False) -> None: def importer_resultats_commune(engine: Engine, verbose: bool = False) -> None:
tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/bd32fcd3-53df-47ac-bf1d-8d8003fe23a1")] tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/bd32fcd3-53df-47ac-bf1d-8d8003fe23a1"),
(2, "https://www.data.gouv.fr/fr/datasets/r/5a8088fd-8168-402a-9f40-c48daab88cd1")]
with Session(engine) as session: with Session(engine) as session:
for resultats_commune in session.execute(select(ResultatsCommuneLegislatives2024)).scalars().all(): for resultats_commune in session.execute(select(ResultatsCommuneLegislatives2024)).scalars().all():
@ -284,7 +286,8 @@ def importer_resultats_commune(engine: Engine, verbose: bool = False) -> None:
def importer_resultats_circo(engine: Engine, verbose: bool = False) -> None: def importer_resultats_circo(engine: Engine, verbose: bool = False) -> None:
tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/5163f2e3-1362-4c35-89a0-1934bb74f2d9")] tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/5163f2e3-1362-4c35-89a0-1934bb74f2d9"),
(2, "https://www.data.gouv.fr/fr/datasets/r/41ed46cd-77c2-4ecc-b8eb-374aa953ca39")]
for tour, file_url in tours: for tour, file_url in tours:
file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-par-circonscription.csv") file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-par-circonscription.csv")
@ -386,7 +389,8 @@ def importer_resultats_circo(engine: Engine, verbose: bool = False) -> None:
def importer_resultats_departement(engine: Engine, verbose: bool = False) -> None: def importer_resultats_departement(engine: Engine, verbose: bool = False) -> None:
tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/78c708c5-5bc5-438d-8379-f432beae3f2b")] tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/78c708c5-5bc5-438d-8379-f432beae3f2b"),
(2, "https://www.data.gouv.fr/fr/datasets/r/8d4a6927-c96f-4cf5-b757-ea745eca26bd")]
for tour, file_url in tours: for tour, file_url in tours:
file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-par-departement.csv") file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-par-departement.csv")
@ -473,7 +477,8 @@ def importer_resultats_departement(engine: Engine, verbose: bool = False) -> Non
def importer_resultats_region(engine: Engine, verbose: bool = False) -> None: def importer_resultats_region(engine: Engine, verbose: bool = False) -> None:
tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/f69ffab7-fe37-494e-ad6d-a7cfc80ddc1f")] tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/f69ffab7-fe37-494e-ad6d-a7cfc80ddc1f"),
(2, "https://www.data.gouv.fr/fr/datasets/r/ac4e272a-3ce2-4f20-941e-fb0ded444a5d")]
for tour, file_url in tours: for tour, file_url in tours:
file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-par-region.csv") file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-par-region.csv")
@ -544,7 +549,9 @@ def importer_resultats_region(engine: Engine, verbose: bool = False) -> None:
def importer_resultats_france(engine: Engine, verbose: bool = False) -> None: def importer_resultats_france(engine: Engine, verbose: bool = False) -> None:
tours = [(1, "https://www.data.gouv.fr/fr/datasets/r/386fd5ac-e7f1-4e0f-8929-12d2c5391081")] # Erreur avec les données France Entière du 1er tour, qui sera j'espère corrigée un jour
tours = [# (1, "https://www.data.gouv.fr/fr/datasets/r/386fd5ac-e7f1-4e0f-8929-12d2c5391081"),
(2, "https://www.data.gouv.fr/fr/datasets/r/f64d2781-4ffa-414b-8f6d-e9d849f2f5e7")]
for tour, file_url in tours: for tour, file_url in tours:
file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-france-entiere.csv") file = get_file(file_url, f"resultats-legislatives-2024-t{tour}-france-entiere.csv")