Преглед на файлове

Add work around for missing columns that have already been dropped in an earlier stage, for method _filter_invalid_data

ogert преди 5 години
родител
ревизия
ad2aff5397
променени са 1 файла, в които са добавени 3 реда и са изтрити 6 реда
  1. 3 6
      cdplib/db_migration/MigrationCleaning.py

+ 3 - 6
cdplib/db_migration/MigrationCleaning.py

@@ -224,21 +224,18 @@ class MigrationCleaning:
         db = self._sql_db
 
         if invalid_mask.sum() == 0:
-
             return data
-        print('INCOMING DATA', data)
-        print('INCOMING DATA COLUMNS', data.columns)
-        print('THIS IS THE INVALID MASK:', invalid_mask)
+
         data_inconsist = data.assign(reason=reason)\
                              .loc[invalid_mask]\
                              .reset_index(drop=True)
 
         if db.check_if_table_exists(self._inconsist_report_table):
             columns = db.get_column_names(tablename=self._inconsist_report_table)
-            print(('COLUMNS: {}, FROM {} TABLE').format(columns, self._inconsist_report_table))
 
             if len(columns) > 0:
-                print('ICONSIST DATA COLUMNS:', data_inconsist.columns)
+                columns_not_in_data = [column for column in colunmns if column not in data.columns]
+                data_inconsist[columns_not_in_data] = 'Column does not exist in the mongo database and has therefore been dropped'
                 data_inconsist = data_inconsist[columns]
 
         db.append_to_table(data=data_inconsist,