X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/predictops.git/blobdiff_plain/1aa2671e4f047322d6957a58a7b44a568b25d67d..20a117b07643f7b3ef305d1e7a6f62f05e33698e:/predictops/target/toarea.py?ds=inline diff --git a/predictops/target/toarea.py b/predictops/target/toarea.py index 72a8ad0..1454e9d 100644 --- a/predictops/target/toarea.py +++ b/predictops/target/toarea.py @@ -1,46 +1,24 @@ 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() + end = datetime.now(), + csv_file = None): + self._area = area + self._csv_file = csv_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._csv_file) as f: + reader = DictReader(f, delimiter=',') + for row in reader: + print(row) +