]> AND Private Git Repository - predictops.git/blobdiff - predictops/target/toarea.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
Standardization and one hot encoding
[predictops.git] / predictops / target / toarea.py
index 72a8ad03139e366e70d66f53f64e4e5ef2d4b3c2..aa6911bb38c632b06eff3c4cca81748ae8067d3a 100644 (file)
@@ -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
+
+