Parcourir la source

update MigrationCleaning to handel bool Ja/Nein

tsteuer il y a 4 ans
Parent
commit
957f713539
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 12 0
      cdplib/db_migration/MigrationCleaning.py

+ 12 - 0
cdplib/db_migration/MigrationCleaning.py

@@ -352,6 +352,18 @@ class MigrationCleaning:
                     self.log.log_and_raise_error(("Column {} contains missing values "
                                         "and cannot be of integer type"
                                         .format(column)))
+                    
+                elif python_type == bool:
+                    
+                    data[column] = data[column].str.lower()
+                    accepted_bool = {'ja': True, 'j': True, '1': True, 
+                                     'yes': True, 'y': True, 'true':True, 
+                                     't': True, 'nein': False, 'n': False,
+                                     'no': False, 'false': False, 'f': False,
+                                     '0': False}
+                    data[column] = data[column].map(accepted_bool)
+                    data[column] = data[column].astype(bool)
+
 
                 elif python_type == str: