Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- # Pull list program
- def pull_list(level):
- 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): ")
- run_num = str(raw_input("Please enter the run number (4 digits): "))
- repext = ''
- if level == 'p':
- repext = [redacted]
- else:
- repext = [redacted]
- print(repext)
- acct_list = []
- try:
- with open(acct_list_file, 'rbU') as infile:
- for line in infile:
- line = line.rstrip('rn')
- acct_list.append(line)
- except IOError as e:
- print 'Unable to open the account number file: %s' % e.strerror
- try:
- with open(repext, 'rbU') as infile:
- print("Opening: ", repext)
- for line in infile:
- acct_num = line[33:41]
- ctrl_num = line[25:32]
- page_cnt = line[121:123]
- doc_type = line[2587:2600]
- if acct_num in acct_list:
- print("%s found!" % acct_num)
- print("Control Number: %sn Total Page Count: %sn BizBranding Type: %s" % (ctrl_num, page_cnt, doc_type))
- except IOError as e:
- print 'Unable to open the file: %s' % e.strerror
- # Audit Info program
- def audit_info(level):
- print("nThis program looks in the production audit.qty file using a property code.")
- prop_code = raw_input(r"Please enter the property code: ")
- prop_code_list = []
- piv_id = ''
- audit_in= ''
- tot_in = ''
- if level == 'p':
- audit_in = [redacted]
- tot_in = [redacted]
- else:
- audit_in = [redacted]
- tot_in = [redacted]
- try:
- audit_qty = open(audit_in, 'rbU')
- tot_file = open(tot_in, 'rbU')
- except IOError as e:
- print 'Unable to open the file: %s' % e.strerror
- my_audit_reader = csv.DictReader(audit_qty, delimiter=';', restkey='Empty Field')
- my_audit_reader.fieldnames = ("Property Code",
- "Pivot ID",
- "Inwork File",
- "Billing Manager E-mail",
- "Total Records",
- "Number of E-Bills",
- "Printed Records",
- "File Date",
- "Hour",
- "Minute",
- "Status")
- # Search for property code
- for line in my_audit_reader:
- if prop_code == line['Property Code']:
- print 'nProperty Code: %s' % line['Property Code']
- print 'Pivot ID: %s' % line['Pivot ID']
- print 'Inwork File: %s' % line['Inwork File']
- print 'Billing Manager E-mail: %s' % line['Billing Manager E-mail']
- print 'Total Records: %s' % line['Total Records']
- print 'Number of E-Bills: %s' % line['Number of E-Bills']
- print 'Printed Records: %s' % line['Printed Records']
- print 'File Date: %s' % line['File Date']
- print 'Status: %sn' % line['Status']
- prop_code_list.append(prop_code)
- piv_id = line['Pivot ID']
- # If found, then search the tot.qty file for it's corresponding status.
- my_tot_reader = csv.DictReader(tot_file, delimiter=';', restkey='Empty Field')
- my_tot_reader.fieldnames = ("Date",
- "Pivot ID",
- "Empty Field",
- "Empty Field",
- "Empty Field",
- "Empty Field",
- "Empty Field",
- "Status")
- for row in my_tot_reader:
- if row['Pivot ID'] == piv_id:
- print('nStatus in the TOT file is: {0}n'.format(row['Status']))
- if prop_code not in prop_code_list:
- print 'nProperty code not found.n'
- audit_qty.close()
- tot_file.close()
- # Main loop
- def main():
- print("Welcome to the Utility Tool!n")
- while True:
- usr_input = raw_input("""Please select one of the following options:
- 1. Pull List
- 2. Audit Info
- 3. Approval Files (WIP)
- 4. Reporting Services (WIP)
- 5. SQLLite Database (WIP)
- Quit = 'q'
- Selection: """)
- if usr_input == 'q': break
- level = raw_input("Please enter your environment level (p for prod, t for test): ")
- if level != "p" and level != "t":
- print("nLevel selection not recognized, please try again.n")
- continue
- else:
- print('nLevel is: {0}n'.format(level))
- # Pull List Program
- if usr_input == '1':
- pull_list(level)
- #Audit Info Program
- elif usr_input == '2':
- audit_info(level)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement