DavMelchi commited on
Commit
97cf335
·
1 Parent(s): 62c48d7

Add row presence tracking and missing entry detection to dump comparison with French logging for entries present in one dump but absent in the other, implement common column intersection validation, extend changes list to include row presence status for missing entries, and add empty common index/column checks with localized warning messages

Browse files
Files changed (1) hide show
  1. apps/dump_compare.py +43 -2
apps/dump_compare.py CHANGED
@@ -77,15 +77,56 @@ if st.button("Run Comparison", type="primary", use_container_width=True):
77
  df_old = df_old[df_old[dist_col_old].notna()].set_index(dist_col_old)
78
  df_new = df_new[df_new[dist_col_new].notna()].set_index(dist_col_new)
79
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  common = df_old.index.intersection(df_new.index)
81
- df_old_common = df_old.loc[common]
82
- df_new_common = df_new.loc[common]
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  mask = (df_old_common != df_new_common) & ~(
85
  df_old_common.isna() & df_new_common.isna()
86
  )
87
 
88
  changes = []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  for dist in mask.index:
90
  for param in mask.columns[mask.loc[dist]]:
91
  if param.strip().lower() == "file_name":
 
77
  df_old = df_old[df_old[dist_col_old].notna()].set_index(dist_col_old)
78
  df_new = df_new[df_new[dist_col_new].notna()].set_index(dist_col_new)
79
 
80
+ missing_in_new = df_old.index.difference(df_new.index)
81
+ missing_in_old = df_new.index.difference(df_old.index)
82
+
83
+ if not missing_in_new.empty:
84
+ logs.append(
85
+ f"{len(missing_in_new)} entrées présentes dans l'ancien dump mais absentes dans le nouveau pour '{sheet}'."
86
+ )
87
+ if not missing_in_old.empty:
88
+ logs.append(
89
+ f"{len(missing_in_old)} entrées présentes dans le nouveau dump mais absentes dans l'ancien pour '{sheet}'."
90
+ )
91
+
92
  common = df_old.index.intersection(df_new.index)
93
+ if common.empty:
94
+ logs.append(f"Aucun Dist_Name commun trouvé pour '{sheet}'.")
95
+ continue
96
+
97
+ common_cols = df_old.columns.intersection(df_new.columns)
98
+ if common_cols.empty:
99
+ logs.append(
100
+ f"Aucune colonne commune entre les dumps pour '{sheet}'."
101
+ )
102
+ continue
103
+
104
+ df_old_common = df_old.loc[common, common_cols]
105
+ df_new_common = df_new.loc[common, common_cols]
106
 
107
  mask = (df_old_common != df_new_common) & ~(
108
  df_old_common.isna() & df_new_common.isna()
109
  )
110
 
111
  changes = []
112
+ for dist in missing_in_new:
113
+ changes.append(
114
+ {
115
+ "Dist_Name": dist,
116
+ "Parameter": "Présence ligne",
117
+ os.path.basename(old_file.name): "Présent",
118
+ os.path.basename(new_file.name): "Manquant",
119
+ }
120
+ )
121
+ for dist in missing_in_old:
122
+ changes.append(
123
+ {
124
+ "Dist_Name": dist,
125
+ "Parameter": "Présence ligne",
126
+ os.path.basename(old_file.name): "Manquant",
127
+ os.path.basename(new_file.name): "Présent",
128
+ }
129
+ )
130
  for dist in mask.index:
131
  for param in mask.columns[mask.loc[dist]]:
132
  if param.strip().lower() == "file_name":