WIP préparation du lecteur de fichier excel
This commit is contained in:
parent
3fec540b67
commit
8856641003
42
purge-registres-deces-insee/excel_in.py
Normal file
42
purge-registres-deces-insee/excel_in.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""
|
||||
Copyright (c) 2020 Sdj Geek
|
||||
Voir le fichier LICENSE
|
||||
|
||||
Classe d'accès aux données du site de l'Église
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import pandas as pd
|
||||
|
||||
from membre_base import MembreBase, MembreProvider
|
||||
|
||||
|
||||
class ExcelIn(MembreProvider):
|
||||
|
||||
def __init__(self, excel_path):
|
||||
self.excel_path = excel_path
|
||||
self.dataframe = None
|
||||
|
||||
def __len__(self):
|
||||
return len(self.dataframe)
|
||||
|
||||
class Member(MembreBase):
|
||||
|
||||
def __init__(self, provider, row):
|
||||
super().__init__(provider)
|
||||
|
||||
def get_name(self):
|
||||
return os.path.basename(self.excel_path)
|
||||
|
||||
def load(self):
|
||||
self.dataframe = pd.read_excel(self.excel_path)
|
||||
return len(self.dataframe)
|
||||
|
||||
def get_member_list(self):
|
||||
for index, row in self.dataframe.iterrows():
|
||||
try:
|
||||
yield self.Member(self, row)
|
||||
except ValueError:
|
||||
print(f"Error with member [{row}]")
|
||||
continue
|
@ -14,12 +14,12 @@ from membre_base import MembreBase, MembreProvider
|
||||
|
||||
class SiteEglise(MembreProvider):
|
||||
|
||||
def __init__(self, unit, cookie_path=None):
|
||||
def __init__(self, unite, cookie_path=None):
|
||||
"""
|
||||
|
||||
:param unite: numéro de l'unité (paroisse, branche)
|
||||
:param cookie_path: chemin vers le répertoire où inscrire les fichiers de sortie
|
||||
"""
|
||||
self.unite = unit
|
||||
self.unite = unite
|
||||
self.cookie_jar = browser_cookie3.firefox(cookie_file=cookie_path)
|
||||
self.as_json = None
|
||||
|
||||
@ -33,7 +33,7 @@ class SiteEglise(MembreProvider):
|
||||
self.completed = False
|
||||
# Données fournies
|
||||
self.r_id = data['legacyCmisId']
|
||||
self.r_last_name, self.r_first_name = data['nameListPreferredLocal'].split(',')
|
||||
self.r_last_name, self.r_first_name = data['nameListPreferredLocal'].upper().split(',')
|
||||
self.r_last_name = self.r_last_name.strip().split(' ')[0]
|
||||
self.r_first_name = self.r_first_name.strip().split(' ')[0]
|
||||
self.r_annee, self.r_mois, self.r_jour = data['birth']['date']['date'].split('-')
|
||||
@ -70,7 +70,7 @@ class SiteEglise(MembreProvider):
|
||||
def get_member_list(self):
|
||||
"""Recevoir la liste des membres
|
||||
|
||||
:param unit_number: numéro de l'unité (paroisse, branche)
|
||||
|
||||
:returns: la liste des membres sous forme d'objet JSON
|
||||
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user