daily pastebin goal
80%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rom openpyxl import load_workbook
  2. from tkinter import Tk
  3. from tkinter.filedialog import askopenfilename
  4. import datetime
  5. import time
  6. #StackOverflow - roganjosh
  7. class ManualReporter:
  8.     def __init__(self):
  9.         Tk().withdraw()
  10.         self.sap_file = None
  11.         self.tracker_file = None
  12.         self.wb_sap = None
  13.         self.wb_wt = None
  14.         self.XT = 0
  15.         self.deadrows = []
  16.        
  17.     def open_sapfile(self):
  18.         self.sap_file = askopenfilename()
  19.         self.wb_sap = load_workbook(filename=self.sap_file)
  20.         # Code to create a backup File in-case of Error or Fault
  21.         copyfile = "Untimed_Report_SAP_" + str(datetime.date.today())+".xlsx"
  22.         self.wb_sap.save(copyfile)
  23.         print(self.sap_file)
  24.     def open_tracker(self):
  25.         self.tracker_file = askopenfilename()
  26.         self.wb_wt = load_workbook(filename=self.tracker_file)
  27.         print(self.tracker_file)
  28.     def check_rows(self):
  29.         sap = self.wb_sap.worksheets[0]
  30.         wt = self.wb_wt.worksheets[0]
  31.         for saprow in sap.iter_rows():
  32.             for wtrow in wt.iter_rows():
  33.                 if (saprow[3].value == wtrow[4].value and int(saprow[2].value) == int(wtrow[5].value)):
  34.                     if wtrow[7].value in ("T","P"): #WT Entry is Marked as T/P
  35.                         if saprow[4].value is "X": #SAP Report Entry is Marked as X
  36.                             self.XT += 1 #Count Changed Status Codes
  37.                             self.deadrows.append(saprow) # Keeps List of The Rows to be Killed Off
  38.                             #saprow.clear() - Insert Here Method to Delete/Clear/Augment Rows -
  39. x = ManualReporter()
  40. x.open_sapfile()
  41. x.open_tracker()
  42. x.check_rows()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top