X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/predictops.git/blobdiff_plain/1aa2671e4f047322d6957a58a7b44a568b25d67d..d6469a787c80df2c938f21d4ae107b84213e238f:/predictops/source/meteofrance.py?ds=sidebyside diff --git a/predictops/source/meteofrance.py b/predictops/source/meteofrance.py index 2326e16..5a885ee 100644 --- a/predictops/source/meteofrance.py +++ b/predictops/source/meteofrance.py @@ -208,13 +208,16 @@ class MeteoFrance: self._dated_features = {} for csv_meteo in listdir(dir_data): date = datetime.strptime(csv_meteo.split('.')[1], '%Y%m') - if date >= self._start and date <= self._end: + if (date >= self._start and date <= self._end)\ + or (date.year == self._start.year and date.month == self._start.month)\ + or (date.year == self._end.year and date.month == self._end.month): logger.info(f'Inserting {csv_meteo} in intervention dictionary') with open(dir_data / csv_meteo, "r") as f: reader = DictReader(f, delimiter=';') for row in reader: if row['numer_sta'] in self._stations: date = datetime.strptime(row['date'], '%Y%m%d%H%M%S') - self._dated_features.setdefault(date,{}).update({dico_features[feat]['name']+'_'+str(self._stations.index(row['numer_sta'])): eval(row[feat].replace('mq','None')) for feat in dico_features}) + if date >= self._start and date <= self._end: + self._dated_features.setdefault(date,{}).update({dico_features[feat]['name']+'_'+str(self._stations.index(row['numer_sta'])): eval(row[feat].replace('mq','None')) for feat in dico_features}) return self._dated_features