Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. import csv
  2.  
  3.  
  4. # Pull list program
  5. def pull_list(level):
  6. acct_list_file = raw_input(r"Please enter the full file path for the list of account numbers (Please format your file so that each line only has one account number): ")
  7. run_num = str(raw_input("Please enter the run number (4 digits): "))
  8. repext = ''
  9. if level == 'p':
  10. repext = [redacted]
  11. else:
  12. repext = [redacted]
  13. print(repext)
  14. acct_list = []
  15. try:
  16. with open(acct_list_file, 'rbU') as infile:
  17. for line in infile:
  18. line = line.rstrip('rn')
  19. acct_list.append(line)
  20. except IOError as e:
  21. print 'Unable to open the account number file: %s' % e.strerror
  22.  
  23. try:
  24. with open(repext, 'rbU') as infile:
  25. print("Opening: ", repext)
  26. for line in infile:
  27. acct_num = line[33:41]
  28. ctrl_num = line[25:32]
  29. page_cnt = line[121:123]
  30. doc_type = line[2587:2600]
  31. if acct_num in acct_list:
  32. print("%s found!" % acct_num)
  33. print("Control Number: %sn Total Page Count: %sn BizBranding Type: %s" % (ctrl_num, page_cnt, doc_type))
  34. except IOError as e:
  35. print 'Unable to open the file: %s' % e.strerror
  36.  
  37.  
  38. # Audit Info program
  39. def audit_info(level):
  40. print("nThis program looks in the production audit.qty file using a property code.")
  41. prop_code = raw_input(r"Please enter the property code: ")
  42. prop_code_list = []
  43. piv_id = ''
  44. audit_in= ''
  45. tot_in = ''
  46. if level == 'p':
  47. audit_in = [redacted]
  48. tot_in = [redacted]
  49. else:
  50. audit_in = [redacted]
  51. tot_in = [redacted]
  52. try:
  53. audit_qty = open(audit_in, 'rbU')
  54. tot_file = open(tot_in, 'rbU')
  55.  
  56. except IOError as e:
  57. print 'Unable to open the file: %s' % e.strerror
  58.  
  59. my_audit_reader = csv.DictReader(audit_qty, delimiter=';', restkey='Empty Field')
  60. my_audit_reader.fieldnames = ("Property Code",
  61. "Pivot ID",
  62. "Inwork File",
  63. "Billing Manager E-mail",
  64. "Total Records",
  65. "Number of E-Bills",
  66. "Printed Records",
  67. "File Date",
  68. "Hour",
  69. "Minute",
  70. "Status")
  71. # Search for property code
  72. for line in my_audit_reader:
  73. if prop_code == line['Property Code']:
  74. print 'nProperty Code: %s' % line['Property Code']
  75. print 'Pivot ID: %s' % line['Pivot ID']
  76. print 'Inwork File: %s' % line['Inwork File']
  77. print 'Billing Manager E-mail: %s' % line['Billing Manager E-mail']
  78. print 'Total Records: %s' % line['Total Records']
  79. print 'Number of E-Bills: %s' % line['Number of E-Bills']
  80. print 'Printed Records: %s' % line['Printed Records']
  81. print 'File Date: %s' % line['File Date']
  82. print 'Status: %sn' % line['Status']
  83. prop_code_list.append(prop_code)
  84. piv_id = line['Pivot ID']
  85.  
  86. # If found, then search the tot.qty file for it's corresponding status.
  87. my_tot_reader = csv.DictReader(tot_file, delimiter=';', restkey='Empty Field')
  88. my_tot_reader.fieldnames = ("Date",
  89. "Pivot ID",
  90. "Empty Field",
  91. "Empty Field",
  92. "Empty Field",
  93. "Empty Field",
  94. "Empty Field",
  95. "Status")
  96. for row in my_tot_reader:
  97. if row['Pivot ID'] == piv_id:
  98. print('nStatus in the TOT file is: {0}n'.format(row['Status']))
  99.  
  100.  
  101. if prop_code not in prop_code_list:
  102. print 'nProperty code not found.n'
  103.  
  104. audit_qty.close()
  105. tot_file.close()
  106.  
  107.  
  108. # Main loop
  109. def main():
  110. print("Welcome to the Utility Tool!n")
  111.  
  112. while True:
  113. usr_input = raw_input("""Please select one of the following options:
  114.  
  115. 1. Pull List
  116. 2. Audit Info
  117. 3. Approval Files (WIP)
  118. 4. Reporting Services (WIP)
  119. 5. SQLLite Database (WIP)
  120. Quit = 'q'
  121. Selection: """)
  122. if usr_input == 'q': break
  123. level = raw_input("Please enter your environment level (p for prod, t for test): ")
  124.  
  125. if level != "p" and level != "t":
  126. print("nLevel selection not recognized, please try again.n")
  127. continue
  128. else:
  129. print('nLevel is: {0}n'.format(level))
  130. # Pull List Program
  131. if usr_input == '1':
  132. pull_list(level)
  133.  
  134. #Audit Info Program
  135. elif usr_input == '2':
  136. audit_info(level)
  137.  
  138.  
  139. if __name__ == '__main__':
  140. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement