X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/predictops.git/blobdiff_plain/1aa2671e4f047322d6957a58a7b44a568b25d67d..f5357178353432c5431fc0fd875b9928a326e4c7:/predictops/target/toarea.py diff --git a/predictops/target/toarea.py b/predictops/target/toarea.py index 72a8ad0..aa6911b 100644 --- a/predictops/target/toarea.py +++ b/predictops/target/toarea.py @@ -1,46 +1,25 @@ from csv import DictReader from datetime import datetime -from os import listdir -from pathlib import Path class ToArea: - def __init__(self, area = None, - start = datetime.strptime('19960101000000', '%Y%m%d%H%M%S'), - end = datetime.now()): - self._get_located_interventions() + def __init__(self, area = None, stream_file = None): + self._area = area + self._stream_file = stream_file + self._get_located_interventions() def _get_located_interventions(self): - self._data_directory = Path.cwd() / 'data' / 'targets' / 'sdis25' - self._dict_interv = {} - for year in range(2006,2018): - if year < 2012: - file_place = self._data_directory / 'interventions' / (str(year)+'.csv') - else: - file_place = self._data_directory / 'victims' / ('Liste_des_victimes_'+str(year)+'.csv') - with open(file_place, "r") as f: - reader = DictReader(f, delimiter='£') - for row in reader: - self._dict_interv.update({ - row['N° intervention']: { - 'X' : row['Coord X'], - 'Y' : row['Coord Y'] - } for row in reader - }) - for csv_file in listdir(self._data_directory / 'interventions'): - with open(self._data_directory / 'interventions' / csv_file, "r") as f: - reader = DictReader(f, delimiter='£') - for row in reader: - if row['N° intervention'] in self._dict_interv: - self._dict_interv[row['N° intervention']].update( - { - 'start': row['Début'], - 'end' : row['Fin'] - }) - else: - print(row['N° intervention']) + with open(self._stream_file) as f: + reader = DictReader(f, delimiter=',') + for row in reader: + start = datetime.strptime(row['start'], '%d/%m/%Y %H:%M:%S') + start.minute = 0 + end = datetime.strptime(row['end'], '%d/%m/%Y %H:%M:%S') + end.minute = 0 + +