Issues fixed:
Updater script had wrong file path.
Tare/gross timestamps confusingly out of order (labelled correct though).
Joined output would truncate last gross weight if there was an odd number of entries
This commit is contained in:
Thaddeus Hughes
2025-10-09 08:08:09 -05:00
parent bb5536614b
commit deea966f6c
12 changed files with 5398 additions and 5384 deletions

17
main.py
View File

@@ -33,6 +33,7 @@ def parse_logs(log_text):
dt = datetime.strptime(ts_line, '%I:%M %p %m/%d/%y')
excel_ts = dt.strftime('%m/%d/%Y %I:%M %p')
pairs.append((weight, units, excel_ts))
print((weight, units, excel_ts))
except ValueError:
i += 1
continue
@@ -54,19 +55,27 @@ def write_csv1(pairs, filename):
def write_csv2(pairs, filename):
with open(filename, 'w', newline='') as f:
writer = csv.writer(f)
writer.writerow(['GROSS_WT', 'TARE_WT', 'NET_WT', 'TARE_T', 'GROSS_T', 'GROSS_UNITS', 'TARE_UNITS', 'NET_UNITS'])
writer.writerow(['GROSS_WT', 'TARE_WT', 'NET_WT', 'GROSS_T', 'TARE_T', 'GROSS_UNITS', 'TARE_UNITS', 'NET_UNITS'])
for j in range(0, len(pairs), 2):
if j + 1 < len(pairs):
gross_weight, gross_units, gross_time = pairs[j]
tare_weight, tare_units, tare_time = pairs[j + 1]
net = gross_weight - tare_weight
# Use gross units for net (assuming consistent units within pairs)
writer.writerow([gross_weight, tare_weight, net, tare_time, gross_time, gross_units, tare_units, gross_units])
net_units = tare_units
if (tare_units != gross_units):
net_units = 'MISMATCH'
net = 'UNIT MISMATCH'
writer.writerow([gross_weight, tare_weight, net, gross_time, tare_time, gross_units, tare_units, net_units])
if (len(pairs) % 2): # if odd number of items
gross_weight, gross_units, gross_time = pairs[-1]
writer.writerow([gross_weight, '', '', gross_time, '', gross_units, '', ''])
def run_update_script():
try:
# Run update.sh script
result = subprocess.run(['sh', 'C:\\Program Files\\rslugger-merger\\update.sh'], capture_output=True, text=True, cwd=os.getcwd())
result = subprocess.run(['sh', 'C:\\Program Files\\rslogger-merger\\update.sh'], capture_output=True, text=True, cwd=os.getcwd())
if result.returncode == 0:
messagebox.showinfo("Success", f"update.sh executed successfully!\n\nOutput:\n{result.stdout}")
else: