Bosch09 commited on
Commit
f61cde8
·
verified ·
1 Parent(s): 54b0078

Upload 6 files

Browse files
Files changed (7) hide show
  1. .gitattributes +1 -0
  2. Bosch.png +0 -0
  3. E.png +3 -0
  4. app.py +510 -0
  5. build_DIRT.bat +52 -0
  6. dirt.spec +51 -0
  7. requirements.txt +2 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ E.png filter=lfs diff=lfs merge=lfs -text
Bosch.png ADDED
E.png ADDED

Git LFS Details

  • SHA256: cf88c00dc0ecdd2e5784a2715f1807f9736a0edc1f0f7f177243ca9e5f38c64f
  • Pointer size: 131 Bytes
  • Size of remote file: 196 kB
app.py ADDED
@@ -0,0 +1,510 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py - FINAL: Full-width layout + scroll restored + logos fixed
2
+ import os, sys, csv, threading, time, tempfile
3
+ import tkinter as tk
4
+ from tkinter import ttk, filedialog, messagebox
5
+ import xlsxwriter
6
+ from PIL import Image, ImageTk
7
+
8
+ APP_TITLE = "Eureka"
9
+ BOSCH_RED = "#ED0006"
10
+ GREEN = "#28A745"
11
+ STATUS_BLUE = "#0066CC"
12
+ HOVER_RED = "#CC0000"
13
+ HOVER_GREEN = "#1E7E34"
14
+ MAX_PREVIEW = 500
15
+
16
+ # -----------------------------
17
+ # Progress Bar Widget
18
+ # -----------------------------
19
+ class CanvasProgress(tk.Frame):
20
+ def __init__(self, master, label="Progress", width=280, height=16):
21
+ super().__init__(master, bg="white")
22
+ self.w = width; self.h = height
23
+ tk.Label(self, text=label, bg="white", fg="#333", font=("Segoe UI", 8, "bold")).pack(anchor="w", padx=5)
24
+ self.canvas = tk.Canvas(self, width=self.w, height=self.h, highlightthickness=0, bg="white")
25
+ self.canvas.pack(padx=5, pady=1)
26
+ self.canvas.create_rectangle(0, 0, self.w, self.h, fill="#E6E6E6", outline="")
27
+ self.fill = self.canvas.create_rectangle(0, 0, 0, self.h, fill=BOSCH_RED, outline="")
28
+ info = tk.Frame(self, bg="white"); info.pack(fill="x", padx=5)
29
+ self.lbl_left = tk.Label(info, text="Processed: 0", anchor="w", bg="white", font=("Segoe UI", 8)); self.lbl_left.pack(side="left")
30
+ self.lbl_center = tk.Label(info, text="0%", bg="white", font=("Segoe UI", 8)); self.lbl_center.pack(side="left", expand=True)
31
+ self.lbl_right = tk.Label(info, text="Total: 0", anchor="e", bg="white", font=("Segoe UI", 8)); self.lbl_right.pack(side="right")
32
+ self.total = self.value = 0; self.start_ts = None
33
+
34
+ def start(self, total):
35
+ self.total = max(0, int(total)); self.value = 0; self.start_ts = time.time(); self._update(0)
36
+ def update(self, value):
37
+ self.value = int(value); self._update(self.value)
38
+ def complete(self):
39
+ self.update(self.total)
40
+
41
+ def _update(self, value):
42
+ try:
43
+ frac = value / self.total if self.total else 0
44
+ fill_w = int(self.w * frac)
45
+ self.canvas.coords(self.fill, 0, 0, fill_w, self.h)
46
+ elapsed = int(time.time() - self.start_ts) if self.start_ts else 0
47
+ rate = value / elapsed if elapsed else 0
48
+ eta = int((self.total - value) / rate) if rate else 0
49
+ self.lbl_left.config(text=f"Processed: {value:,}")
50
+ self.lbl_center.config(text=f"{int(frac*100)}% | ETA {eta}s")
51
+ self.lbl_right.config(text=f"Total: {self.total:,}")
52
+ except Exception as e:
53
+ pass
54
+
55
+ # -----------------------------
56
+ # Value Normalizer
57
+ # -----------------------------
58
+ def normalize_value(val, match_case, ignore_zeros, decimal_mode, dec_exact):
59
+ s = str(val).strip()
60
+ s = s.replace('₹', '').replace('$', '').replace('€', '').replace(',', '').strip()
61
+ if not match_case:
62
+ s = s.lower()
63
+ if ignore_zeros:
64
+ s = s.lstrip('0')
65
+ if not s: s = '0'
66
+ if decimal_mode == "ignore" and not dec_exact:
67
+ if '.' in s:
68
+ s = s.rstrip('0').rstrip('.') if '.' in s else s
69
+ elif decimal_mode == "ignore_decimal":
70
+ s = s.split('.')[0]
71
+ return s
72
+
73
+ # -----------------------------
74
+ # Fast header + row count
75
+ # -----------------------------
76
+ def headers_and_rowcount(path):
77
+ with open(path, 'r', encoding='utf-8-sig', newline='') as f:
78
+ r = csv.reader(f)
79
+ headers = next(r, [])
80
+ count = sum(1 for row in r if any(str(c).strip() for c in row))
81
+ return headers, count
82
+
83
+ # -----------------------------
84
+ # Streaming compare - ROW FIX
85
+ # -----------------------------
86
+ def compare_streamed(src_path, tgt_path, progress_cb=None, stop_event=None,
87
+ match_case=False, ignore_zeros=False, decimal_mode="ignore", dec_exact=False):
88
+ src_h, src_n = headers_and_rowcount(src_path)
89
+ tgt_h, tgt_n = headers_and_rowcount(tgt_path)
90
+ all_h = sorted(set(src_h) | set(tgt_h))
91
+
92
+ preview = []
93
+ spill = tempfile.NamedTemporaryFile(prefix="dirt_", suffix=".csv", delete=False, mode="w", newline="", encoding="utf-8")
94
+ writer = csv.writer(spill); writer.writerow(["Row","Column","Source","Target"])
95
+
96
+ rows_diff = cells_diff = processed = 0
97
+ total = min(src_n, tgt_n)
98
+
99
+ with open(src_path, "r", encoding="utf-8-sig", newline="") as sf, \
100
+ open(tgt_path, "r", encoding="utf-8-sig", newline="") as tf:
101
+ sr = csv.DictReader(sf); tr = csv.DictReader(tf)
102
+ for src_row, tgt_row in zip(sr, tr):
103
+ if stop_event and stop_event.is_set(): break
104
+ diff_in_row = False
105
+ row_idx = processed + 2 # ← Excel row = processed + 2
106
+ for col in all_h:
107
+ sv = normalize_value(src_row.get(col, ""), match_case, ignore_zeros, decimal_mode, dec_exact)
108
+ tv = normalize_value(tgt_row.get(col, ""), match_case, ignore_zeros, decimal_mode, dec_exact)
109
+ if sv != tv:
110
+ rec = (row_idx, col, src_row.get(col, ""), tgt_row.get(col, ""))
111
+ if len(preview) < MAX_PREVIEW: preview.append(rec)
112
+ writer.writerow(rec); cells_diff += 1; diff_in_row = True
113
+ if diff_in_row: rows_diff += 1
114
+ processed += 1
115
+ if progress_cb and processed % 1000 == 0:
116
+ progress_cb(processed, total)
117
+
118
+ spill.close()
119
+ stats = {
120
+ "src_rows": src_n, "tgt_rows": tgt_n, "rows_match": int(src_n==tgt_n),
121
+ "src_cols": len(src_h), "tgt_cols": len(tgt_h), "cols_match": int(len(src_h)==len(tgt_h)),
122
+ "rows_with_diff": rows_diff, "cells_with_diff": cells_diff,
123
+ "extra_src_rows": src_n - total, "extra_tgt_rows": tgt_n - total,
124
+ "spill_path": spill.name
125
+ }
126
+ return stats, preview
127
+
128
+ # -----------------------------
129
+ # Export
130
+ # -----------------------------
131
+ def export_report(path, stats, prog=None, stop=None):
132
+ with xlsxwriter.Workbook(path) as wb:
133
+ bold = wb.add_format({'bold':True, 'font_color':BOSCH_RED})
134
+ ws = wb.add_worksheet("Summary")
135
+ for i, k in enumerate(["src_rows","tgt_rows","rows_match","src_cols","tgt_cols","cols_match",
136
+ "rows_with_diff","cells_with_diff","extra_src_rows","extra_tgt_rows"]):
137
+ ws.write(i, 0, k, bold); ws.write(i, 1, stats.get(k,""))
138
+ if prog: prog.update(1)
139
+
140
+ ws2 = wb.add_worksheet("Cell Differences")
141
+ ws2.write_row(0,0,["Row","Column","Source","Target"], bold)
142
+ spill = stats.get("spill_path")
143
+ if spill and os.path.exists(spill):
144
+ with open(spill, "r", encoding="utf-8", newline="") as f:
145
+ r = csv.reader(f); next(r,None)
146
+ total = stats.get("cells_with_diff",0)
147
+ if prog: prog.start(max(1,total))
148
+ for i, row in enumerate(r, 1):
149
+ if stop and stop.is_set(): break
150
+ ws2.write_row(i,0,row)
151
+ if prog and i % 1000 == 0: prog.update(i)
152
+ if spill and os.path.exists(spill):
153
+ try: os.unlink(spill)
154
+ except: pass
155
+
156
+ # -----------------------------
157
+ # UI Proxy
158
+ # -----------------------------
159
+ class UIProxy:
160
+ def __init__(self, app, bar): self.app=app; self.bar=bar
161
+ def start(self, t): self.app.ui(self.bar.start, t)
162
+ def update(self, v): self.app.ui(self.bar.update, v)
163
+ def complete(self): self.app.ui(self.bar.complete)
164
+
165
+ # -----------------------------
166
+ # Main App - FINAL
167
+ # -----------------------------
168
+ class DIRTApp:
169
+ def __init__(self, root):
170
+ self.root = root
171
+ self.root.title(APP_TITLE)
172
+ self.root.configure(bg="white")
173
+ self.root.state('zoomed') # ← FULL SCREEN
174
+
175
+ self.stop = threading.Event()
176
+ self.stats = None
177
+
178
+ self.var_case = tk.BooleanVar(value=False)
179
+ self.var_zeros = tk.BooleanVar(value=False)
180
+ self.var_dec_exact = tk.BooleanVar(value=False)
181
+ self.var_decimal_mode = tk.StringVar(value="ignore")
182
+
183
+ self.src_filename = tk.StringVar()
184
+ self.tgt_filename = tk.StringVar()
185
+
186
+ self.summary_labels = {}
187
+
188
+ self._ui()
189
+
190
+ def _ui(self):
191
+ # Global font
192
+ self.root.option_add("*Font", ("Segoe UI", 9))
193
+ self.root.option_add("*Label.Font", ("Segoe UI", 9))
194
+ self.root.option_add("*Button.Font", ("Segoe UI", 10, "bold"))
195
+
196
+ # Scrollable canvas
197
+ canvas = tk.Canvas(self.root, bg="white")
198
+ scrollbar = ttk.Scrollbar(self.root, orient="vertical", command=canvas.yview)
199
+ scrollable_frame = tk.Frame(canvas, bg="white")
200
+
201
+ scrollable_frame.bind(
202
+ "<Configure>",
203
+ lambda e: canvas.configure(scrollregion=canvas.bbox("all"))
204
+ )
205
+
206
+ canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
207
+ canvas.configure(yscrollcommand=scrollbar.set)
208
+
209
+ canvas.pack(side="left", fill="both", expand=True)
210
+ scrollbar.pack(side="right", fill="y")
211
+
212
+ # Header - FULL WIDTH
213
+ header = tk.Frame(scrollable_frame, bg="white")
214
+ header.pack(fill="x", pady=10, padx=20)
215
+ header.grid_columnconfigure(0, weight=1)
216
+ header.grid_columnconfigure(1, weight=1)
217
+
218
+ # EUREKA LOGO (LEFT)
219
+ left_frame = tk.Frame(header, bg="white")
220
+ left_frame.grid(row=0, column=0, sticky="w")
221
+ try:
222
+ e_path = "E.png"
223
+ if getattr(sys, '_MEIPASS', None):
224
+ e_path = os.path.join(sys._MEIPASS, "E.png")
225
+ e_img = Image.open(e_path)
226
+ e_img = e_img.resize((120, 120), Image.Resampling.LANCZOS)
227
+ e_photo = ImageTk.PhotoImage(e_img)
228
+ tk.Label(left_frame, image=e_photo, bg="white").pack()
229
+ left_frame.image = e_photo
230
+ except:
231
+ tk.Label(left_frame, text="EUREKA", font=("Segoe UI", 32, "bold"), fg=BOSCH_RED, bg="white").pack()
232
+ tk.Label(left_frame, text="Developed by ASTRA Project Team", font=("Segoe UI", 10), fg="gray", bg="white").pack()
233
+
234
+ # BOSCH LOGO (RIGHT)
235
+ try:
236
+ base_path = os.path.dirname(sys.argv[0]) if getattr(sys, 'frozen', False) else os.path.dirname(__file__)
237
+ bosch_path = os.path.join(base_path, "Bosch.png")
238
+ if getattr(sys, '_MEIPASS', None):
239
+ bosch_path = os.path.join(sys._MEIPASS, "Bosch.png")
240
+ bosch_img = Image.open(bosch_path)
241
+ bosch_img = bosch_img.resize((100, 100), Image.Resampling.LANCZOS)
242
+ bosch_photo = ImageTk.PhotoImage(bosch_img)
243
+ tk.Label(header, image=bosch_photo, bg="white").grid(row=0, column=1, sticky="e")
244
+ header.image2 = bosch_photo
245
+ except:
246
+ tk.Label(header, text="BOSCH", font=("Segoe UI", 24, "bold"), fg=BOSCH_RED, bg="white").grid(row=0, column=1, sticky="e")
247
+
248
+ # Load + Progress Row - FULL WIDTH
249
+ top_row = tk.Frame(scrollable_frame, bg="white")
250
+ top_row.pack(fill="x", padx=20, pady=10)
251
+ top_row.grid_columnconfigure(0, weight=1)
252
+ top_row.grid_columnconfigure(1, weight=1)
253
+
254
+ # Load Data + Filters
255
+ load_box = tk.LabelFrame(top_row, text="LOAD DATA", bg="white", fg=BOSCH_RED, font=("Segoe UI", 10, "bold"))
256
+ load_box.grid(row=0, column=0, sticky="nsew", padx=(0, 10))
257
+
258
+ f = tk.Frame(load_box, bg="white")
259
+ f.pack(fill="x", padx=10, pady=5)
260
+ for i, (txt, key, var) in enumerate([
261
+ ("Source CSV:", "src", self.src_filename),
262
+ ("Target CSV:", "tgt", self.tgt_filename)
263
+ ]):
264
+ tk.Label(f, text=txt, bg="white").grid(row=i, column=0, sticky="w", pady=3)
265
+ e = tk.Entry(f, width=50)
266
+ e.grid(row=i, column=1, sticky="ew", padx=5)
267
+ tk.Button(f, text="Browse", command=lambda k=key: getattr(self,f"browse_{k}")()).grid(row=i, column=2, padx=5)
268
+ tk.Label(f, textvariable=var, bg="white", fg="#333").grid(row=i, column=3, sticky="w", padx=10)
269
+ setattr(self, f"{key}_entry", e)
270
+ f.grid_columnconfigure(1, weight=1)
271
+
272
+ filters_inner = tk.Frame(load_box, bg="white")
273
+ filters_inner.pack(fill="x", padx=10, pady=5)
274
+ tk.Checkbutton(filters_inner, text="Match case (case-sensitive)", variable=self.var_case, bg="white").grid(row=0, column=0, sticky="w", padx=5)
275
+ tk.Checkbutton(filters_inner, text="Ignore leading zeros", variable=self.var_zeros, bg="white").grid(row=0, column=1, sticky="w", padx=5)
276
+
277
+ tk.Label(filters_inner, text="Decimals:", bg="white").grid(row=1, column=0, sticky="w", padx=5, pady=2)
278
+ ttk.Radiobutton(filters_inner, text="Ignore trailing zeros", variable=self.var_decimal_mode, value="ignore").grid(row=1, column=1, sticky="w", padx=5)
279
+ ttk.Radiobutton(filters_inner, text="Strict text match", variable=self.var_decimal_mode, value="strict").grid(row=2, column=1, sticky="w", padx=5)
280
+ ttk.Radiobutton(filters_inner, text="Ignore decimals entirely", variable=self.var_decimal_mode, value="ignore_decimal").grid(row=3, column=1, sticky="w", padx=5)
281
+
282
+ tk.Checkbutton(filters_inner, text="Compare decimals exactly", variable=self.var_dec_exact, bg="white").grid(row=4, column=0, columnspan=2, sticky="w", padx=5, pady=2)
283
+
284
+ # Progress Box - FULL WIDTH
285
+ prog_box = tk.LabelFrame(top_row, text="PROGRESS & STATUS", bg="white", fg=BOSCH_RED, font=("Segoe UI", 10, "bold"))
286
+ prog_box.grid(row=0, column=1, sticky="nsew", padx=(10, 0))
287
+ self.status_label = tk.Label(prog_box, text="STATUS: Ready.", bg="white", fg=STATUS_BLUE, font=("Segoe UI", 10, "bold"), anchor="w")
288
+ self.status_label.pack(fill="x", padx=10, pady=5)
289
+ self.p_cmp = CanvasProgress(prog_box, "Compare Progress", width=400)
290
+ self.p_cmp.pack(fill="x", padx=10, pady=2)
291
+ self.p_exp = CanvasProgress(prog_box, "Export Progress", width=400)
292
+ self.p_exp.pack(fill="x", padx=10, pady=2)
293
+
294
+ # Buttons
295
+ btn_frame = tk.Frame(scrollable_frame, bg="white")
296
+ btn_frame.pack(pady=10)
297
+
298
+ def hover(btn, normal, hover):
299
+ btn.bind("<Enter>", lambda e: btn.config(bg=hover))
300
+ btn.bind("<Leave>", lambda e: btn.config(bg=normal))
301
+
302
+ self.btn_cmp = tk.Button(btn_frame, text="COMPARE", bg=BOSCH_RED, fg="white", width=15, command=self.start_compare)
303
+ self.btn_cmp.pack(side="left", padx=8)
304
+ hover(self.btn_cmp, BOSCH_RED, HOVER_RED)
305
+
306
+ self.btn_can = tk.Button(btn_frame, text="CANCEL", bg=BOSCH_RED, fg="white", width=15, command=self.cancel)
307
+ self.btn_can.pack(side="left", padx=8)
308
+ hover(self.btn_can, BOSCH_RED, HOVER_RED)
309
+
310
+ self.btn_reset = tk.Button(btn_frame, text="RESET", bg=BOSCH_RED, fg="white", width=15, command=self.reset)
311
+ self.btn_reset.pack(side="left", padx=8)
312
+ hover(self.btn_reset, BOSCH_RED, HOVER_RED)
313
+
314
+ self.btn_exp = tk.Button(btn_frame, text="EXPORT EXCEL", bg=GREEN, fg="white", width=15, command=self.export)
315
+ self.btn_exp.pack(side="left", padx=8)
316
+ hover(self.btn_exp, GREEN, HOVER_GREEN)
317
+
318
+ # Summary - FULL WIDTH
319
+ self.summary_frame = tk.LabelFrame(scrollable_frame, text="SUMMARY", bg="white", fg=BOSCH_RED, font=("Segoe UI", 10, "bold"))
320
+ self.summary_frame.pack(fill="x", padx=20, pady=10)
321
+ self.summary_frame.grid_columnconfigure(0, weight=1)
322
+ self.summary_frame.grid_columnconfigure(1, weight=1)
323
+
324
+ labels = [
325
+ ("Source Rows", "Target Rows"),
326
+ ("Source Cols", "Target Cols"),
327
+ ("Rows with diff", "Cols Match"),
328
+ ("Extra src rows", "Cells with diff"),
329
+ ("Extra tgt rows", "")
330
+ ]
331
+
332
+ for row_idx, (l1, l2) in enumerate(labels):
333
+ tk.Label(self.summary_frame, text=l1 + ":", bg="white", anchor="w").grid(row=row_idx, column=0, sticky="w", padx=15, pady=3)
334
+ self.summary_labels[l1] = tk.Label(self.summary_frame, text="", bg="white", fg="blue", anchor="w")
335
+ self.summary_labels[l1].grid(row=row_idx, column=1, sticky="w", padx=5, pady=3)
336
+
337
+ if l2:
338
+ tk.Label(self.summary_frame, text=l2 + ":", bg="white", anchor="w").grid(row=row_idx, column=2, sticky="w", padx=15, pady=3)
339
+ self.summary_labels[l2] = tk.Label(self.summary_frame, text="", bg="white", fg="blue", anchor="w")
340
+ self.summary_labels[l2].grid(row=row_idx, column=3, sticky="w", padx=5, pady=3)
341
+
342
+ # Preview - FULL WIDTH + ZEBRA
343
+ preview_frame = tk.LabelFrame(scrollable_frame, text="DIFFERENCES PREVIEW (500 max)", bg="white", fg=BOSCH_RED, font=("Segoe UI", 10, "bold"))
344
+ preview_frame.pack(fill="both", expand=True, padx=20, pady=10)
345
+ preview_frame.grid_rowconfigure(0, weight=1)
346
+ preview_frame.grid_columnconfigure(0, weight=1)
347
+
348
+ tf = tk.Frame(preview_frame)
349
+ tf.grid(row=0, column=0, sticky="nsew")
350
+ tf.grid_rowconfigure(0, weight=1)
351
+ tf.grid_columnconfigure(0, weight=1)
352
+
353
+ self.tree = ttk.Treeview(tf, columns=("Row","Col","Src","Tgt"), show="headings", height=20)
354
+ for c,w in zip(("Row","Col","Src","Tgt"), (80,180,300,300)):
355
+ self.tree.heading(c, text=c)
356
+ self.tree.column(c, width=w, anchor="center")
357
+ self.tree.tag_configure("even", background="#F9F9F9")
358
+ sb = ttk.Scrollbar(tf, orient="vertical", command=self.tree.yview)
359
+ self.tree.configure(yscrollcommand=sb.set)
360
+ sb.grid(row=0, column=1, sticky="ns")
361
+ self.tree.grid(row=0, column=0, sticky="nsew")
362
+
363
+ exp_frame = tk.Frame(preview_frame, bg="white")
364
+ exp_frame.grid(row=1, column=0, pady=5)
365
+ self.btn_exp_table = tk.Button(exp_frame, text="EXPORT EXCEL", bg=GREEN, fg="white", command=self.export)
366
+ self.btn_exp_table.pack()
367
+ hover(self.btn_exp_table, GREEN, HOVER_GREEN)
368
+
369
+ # Scroll for whole app
370
+ def _on_mousewheel(event):
371
+ canvas.yview_scroll(-1*(event.delta//120), "units")
372
+ canvas.bind_all("<MouseWheel>", _on_mousewheel)
373
+
374
+ def ui(self, fn, *a, **k):
375
+ self.root.after(0, lambda: fn(*a, **k))
376
+
377
+ def browse_src(self): self._browse("src", self.src_filename)
378
+ def browse_tgt(self): self._browse("tgt", self.tgt_filename)
379
+ def _browse(self, which, var):
380
+ f = filedialog.askopenfilename(filetypes=[("CSV","*.csv")])
381
+ if f:
382
+ entry = getattr(self, f"{which}_entry")
383
+ entry.delete(0, "end"); entry.insert(0, f)
384
+ var.set(os.path.basename(f))
385
+
386
+ def cancel(self):
387
+ if self.stop.is_set():
388
+ messagebox.showwarning("In Progress", "Operation already stopping.")
389
+ else:
390
+ self.stop.set(); self.status("STATUS: Cancelling...")
391
+
392
+ def reset(self):
393
+ if self.stop.is_set() or self.btn_cmp['state'] == 'disabled':
394
+ messagebox.showwarning("In Progress", "Please wait until current operation completes.")
395
+ return
396
+ self.src_entry.delete(0, "end"); self.tgt_entry.delete(0, "end")
397
+ self.src_filename.set(""); self.tgt_filename.set("")
398
+ self.var_case.set(False); self.var_zeros.set(False); self.var_dec_exact.set(False)
399
+ self.var_decimal_mode.set("ignore")
400
+ for i in self.tree.get_children(): self.tree.delete(i)
401
+ for val in self.summary_labels.values(): val.config(text="")
402
+ self.status("STATUS: Ready.")
403
+ self.p_cmp.start(1); self.p_cmp.update(0); self.p_exp.start(1); self.p_exp.update(0)
404
+
405
+ def status(self, txt):
406
+ self.ui(self.status_label.config, text=txt)
407
+
408
+ def start_compare(self):
409
+ if self.btn_cmp['state'] == 'disabled':
410
+ messagebox.showwarning("In Progress", "Comparison already running.")
411
+ return
412
+ src = self.src_entry.get().strip()
413
+ tgt = self.tgt_entry.get().strip()
414
+ if not (src and tgt and os.path.exists(src) and os.path.exists(tgt)):
415
+ messagebox.showerror("Error", "Please select two valid CSV files.")
416
+ return
417
+
418
+ match_case = self.var_case.get()
419
+ ignore_zeros = self.var_zeros.get()
420
+ dec_exact = self.var_dec_exact.get()
421
+ decimal_mode = self.var_decimal_mode.get()
422
+
423
+ self.stop.clear(); self.btn_cmp.config(state="disabled"); self.btn_can.config(state="normal")
424
+ threading.Thread(
425
+ target=self._compare,
426
+ args=(src, tgt, match_case, ignore_zeros, decimal_mode, dec_exact),
427
+ daemon=True
428
+ ).start()
429
+
430
+ def _compare(self, src, tgt, match_case, ignore_zeros, decimal_mode, dec_exact):
431
+ try:
432
+ self.status("STATUS: Scanning files...")
433
+ total = min(*[headers_and_rowcount(p)[1] for p in (src,tgt)])
434
+ self.ui(self.p_cmp.start, total or 1)
435
+
436
+ def prog(v,_): self.ui(self.p_cmp.update, v)
437
+ stats, preview = compare_streamed(src, tgt, prog, self.stop,
438
+ match_case, ignore_zeros, decimal_mode, dec_exact)
439
+ if self.stop.is_set():
440
+ self.status("STATUS: Cancelled."); return
441
+
442
+ self.stats = stats
443
+ self.ui(lambda: self._show(preview, stats))
444
+ except Exception as e:
445
+ self.ui(messagebox.showerror, "Error", str(e))
446
+ finally:
447
+ self.ui(self.btn_cmp.config, state="normal")
448
+ self.ui(self.btn_can.config, state="disabled")
449
+
450
+ def _show(self, preview, stats):
451
+ for i in self.tree.get_children(): self.tree.delete(i)
452
+ for idx, r in enumerate(preview):
453
+ tag = "even" if idx % 2 == 0 else ""
454
+ self.tree.insert("", "end", values=r, tags=(tag,))
455
+ self.p_cmp.complete()
456
+
457
+ values = {
458
+ "Source Rows": stats["src_rows"],
459
+ "Target Rows": stats["tgt_rows"],
460
+ "Source Cols": stats["src_cols"],
461
+ "Target Cols": stats["tgt_cols"],
462
+ "Rows with diff": stats["rows_with_diff"],
463
+ "Cols Match": "Yes" if stats["cols_match"] else "No",
464
+ "Cells with diff": stats["cells_with_diff"],
465
+ "Extra src rows": stats["extra_src_rows"],
466
+ "Extra tgt rows": stats["extra_tgt_rows"]
467
+ }
468
+
469
+ for label, val in values.items():
470
+ self.summary_labels[label].config(text=str(val))
471
+
472
+ diff_text = f"STATUS: Done — {stats['rows_with_diff']:,} rows, {stats['cells_with_diff']:,} cells differ."
473
+ self.status(diff_text)
474
+
475
+ def export(self):
476
+ if not self.stats:
477
+ messagebox.showwarning("No Data", "Run comparison first.")
478
+ return
479
+ if self.btn_exp['state'] == 'disabled':
480
+ messagebox.showwarning("In Progress", "Export already running.")
481
+ return
482
+ out = filedialog.asksaveasfilename(defaultextension=".xlsx", filetypes=[("Excel","*.xlsx")])
483
+ if not out: return
484
+ self.stop.clear(); self.btn_exp.config(state="disabled"); self.btn_can.config(state="normal")
485
+ threading.Thread(target=self._export, args=(out,), daemon=True).start()
486
+
487
+ def _export(self, path):
488
+ try:
489
+ p = UIProxy(self, self.p_exp)
490
+ p.start(self.stats.get("cells_with_diff",1))
491
+ export_report(path, self.stats, p, self.stop)
492
+ if not self.stop.is_set():
493
+ self.status(f"STATUS: Saved: {os.path.basename(path)}")
494
+ self.ui(messagebox.showinfo, "Saved", f"Report saved:\n{path}")
495
+ p.complete()
496
+ except Exception as e:
497
+ self.ui(messagebox.showerror, "Error", str(e))
498
+ finally:
499
+ self.ui(self.btn_exp.config, state="normal")
500
+ self.ui(self.btn_can.config, state="disabled")
501
+
502
+ def main():
503
+ root = tk.Tk()
504
+ DIRTApp(root)
505
+ root.mainloop()
506
+
507
+ if __name__ == "__main__":
508
+ if getattr(sys, 'frozen', False):
509
+ os.chdir(sys._MEIPASS)
510
+ main()
build_DIRT.bat ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ setlocal ENABLEDELAYEDEXPANSION
3
+
4
+ cd /d "%~dp0"
5
+
6
+ echo.
7
+ echo [1/6] Checking Python...
8
+ where py >nul 2>nul && set PY=py || where python >nul 2>nul && set PY=python
9
+ if not defined PY (
10
+ echo ERROR: Python not found.
11
+ pause & exit /b 1
12
+ )
13
+
14
+ echo Using: %PY%
15
+ echo.
16
+
17
+ echo [2/6] Creating virtual environment...
18
+ if not exist ".venv" %PY% -m venv .venv
19
+ call .venv\Scripts\activate.bat || (echo Failed to activate venv & pause & exit /b 1)
20
+
21
+ echo.
22
+ echo [3/6] Upgrading pip...
23
+ python -m pip install --upgrade pip
24
+
25
+ echo.
26
+ echo [4/6] Installing requirements...
27
+ pip install -r requirements.txt
28
+ pip install pyinstaller
29
+
30
+ echo.
31
+ echo [5/6] CLEANING OLD BUILDS...
32
+ rmdir /s /q build dist 2>nul
33
+ :: DO NOT DELETE DIRT.spec
34
+
35
+ echo.
36
+ echo [6/6] BUILDING DIRT.EXE...
37
+ pyinstaller DIRT.spec --log-level=INFO
38
+ if %ERRORLEVEL% neq 0 (
39
+ echo.
40
+ echo BUILD FAILED
41
+ pause & exit /b 1
42
+ )
43
+
44
+ echo.
45
+ echo SUCCESS! Opening folder...
46
+ explorer.exe "dist\DIRT"
47
+
48
+ echo.
49
+ echo Double-click DIRT.exe to run.
50
+ echo.
51
+ pause
52
+ endlocal
dirt.spec ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # DIRT.spec
2
+ # -*- mode: python ; coding: utf-8 -*-
3
+
4
+ from PyInstaller.utils.hooks import collect_submodules
5
+ import os
6
+
7
+ block_cipher = None
8
+
9
+ current_dir = os.path.dirname(__file__) if '__file__' in globals() else os.getcwd()
10
+ e_png = os.path.join(current_dir, 'E.png')
11
+ bosch_png = os.path.join(current_dir, 'Bosch.png')
12
+
13
+ datas = []
14
+ for path in [e_png, bosch_png]:
15
+ if os.path.exists(path):
16
+ datas.append((path, '.'))
17
+
18
+ a = Analysis(
19
+ ['app.py'],
20
+ pathex=[],
21
+ binaries=[],
22
+ datas=datas,
23
+ hiddenimports=collect_submodules('xlsxwriter') + ['tkinter', '_tkinter', 'tcl', 'tk'],
24
+ hookspath=[],
25
+ runtime_hooks=[],
26
+ excludes=[],
27
+ noarchive=False,
28
+ )
29
+
30
+ pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
31
+
32
+ exe = EXE(
33
+ pyz,
34
+ a.scripts,
35
+ [],
36
+ exclude_binaries=True,
37
+ name='DIRT',
38
+ debug=False,
39
+ strip=False,
40
+ upx=False,
41
+ console=False,
42
+ )
43
+
44
+ coll = COLLECT(
45
+ exe,
46
+ a.binaries,
47
+ a.datas,
48
+ strip=False,
49
+ upx=False,
50
+ name='DIRT'
51
+ )
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ xlsxwriter==3.2.0
2
+ Pillow==10.0.0