Browse Source

Changelog update bug resolved

Akash Singh 3 years ago
parent
commit
9bd50fb869
1 changed files with 40 additions and 41 deletions
  1. 40 41
      CloneXls/ChangeLogPandas.py

+ 40 - 41
CloneXls/ChangeLogPandas.py

@@ -176,48 +176,47 @@ class ChangeLog:
         changes = []
         source_sht.fillna("", inplace=True)
         clone_sht.fillna("", inplace=True)
-        if not source_sht.index.equals(clone_sht.index):
-            merged_source = source_sht.merge(clone_sht, indicator=True, how='outer')
-            source_changes = merged_source[merged_source['_merge'] != 'both']
-            del source_changes["_merge"]
-            clone_list = clone_sht.values.tolist()
-            clone_index = clone_sht.index.values.tolist()
-            data_dic = {}
-            for data, i in zip(source_changes.values.tolist(), source_changes.index.values.tolist()):
-                if i < len(source_sht):
-                    if i not in data_dic:
-                        data_dic[i] = [data, ""]
-                else:
-                    if data in clone_list:
-                        index = clone_index[clone_list.index(data)]
-                        if index in data_dic:
-                            data_dic[index][1] = data
-                        else:
-                            data_dic[index] = ["", data]
+        merged_source = source_sht.merge(clone_sht, indicator=True, how='outer')
+        source_changes = merged_source[merged_source['_merge'] != 'both']
+        del source_changes["_merge"]
+        clone_list = clone_sht.values.tolist()
+        clone_index = clone_sht.index.values.tolist()
+        data_dic = {}
+        for data, i in zip(source_changes.values.tolist(), source_changes.index.values.tolist()):
+            if i < len(source_sht):
+                if i not in data_dic:
+                    data_dic[i] = [data, ""]
+            else:
+                if data in clone_list:
+                    index = clone_index[clone_list.index(data)]
+                    if index in data_dic:
+                        data_dic[index][1] = data
+                    else:
+                        data_dic[index] = ["", data]
 
-            for data in data_dic:
-                new_value = data_dic[data][0]
-                old_value = data_dic[data][1]
-                if old_value and new_value and len(old_value) == len(new_value):
-                    for old, new in zip(old_value, new_value):
-                        if old != new:
-                            changes.append([
-                                datetime.now().strftime("%d-%m-%Y %H:%M"),
-                                sheetname,
-                                source_sht.columns.values.tolist()[new_value.index(new)],
-                                data + 2,
-                                old,
-                                new
-                            ])
-                else:
-                    changes.append([
-                        datetime.now().strftime("%d-%m-%Y %H:%M"),
-                        sheetname,
-                        "-",
-                        data + 2,
-                        old_value,
-                        new_value
-                    ])
+        for data in data_dic:
+            new_value = data_dic[data][0]
+            old_value = data_dic[data][1]
+            if old_value and new_value and len(old_value) == len(new_value):
+                for old, new in zip(old_value, new_value):
+                    if old != new:
+                        changes.append([
+                            datetime.now().strftime("%d-%m-%Y %H:%M"),
+                            sheetname,
+                            source_sht.columns.values.tolist()[new_value.index(new)],
+                            data + 2,
+                            old,
+                            new
+                        ])
+            else:
+                changes.append([
+                    datetime.now().strftime("%d-%m-%Y %H:%M"),
+                    sheetname,
+                    "-",
+                    data + 2,
+                    old_value,
+                    new_value
+                ])
         return changes
 
     def update_change_logs(self, logs, clone):