Oct-19-2018, 08:03 PM
Using Linux Mint 18.2 and running programs from Python 3.5 which is the default for 18.2.
Upon of doing python Basic-Menu.py and making selection '3' the file names
are not presented. On entering a number of 0 to and entering '1' for file name,
Next choice is month number using '1' again. The results displayed do not
include: filename, # Items:, Month Expenses:, Paid Cash >, Paid Check >, Paid C Card >.
But running the program from the command line all is displayed correctly.
How to remedy this would be helpful.
tia
oldcity
Upon of doing python Basic-Menu.py and making selection '3' the file names
are not presented. On entering a number of 0 to and entering '1' for file name,
Next choice is month number using '1' again. The results displayed do not
include: filename, # Items:, Month Expenses:, Paid Cash >, Paid Check >, Paid C Card >.
But running the program from the command line all is displayed correctly.
How to remedy this would be helpful.
tia
oldcity
############################################## #!/usr/bin/python3 # Basic-Menu.py import subprocess ans=True while ans: print (""" 1.Add Expenses 2.View/Print Expenses 3.Verify Entries 4.Exit/Quit """) ans=raw_input("What would you like to do? ") print(" ") if ans=="1": # subprocess.call("./Add-Expenses.py") print(" ") elif ans=="2": # subprocess.call("./Expense-Rpt.py") print(" ") elif ans=="3": subprocess.call("./Verify-Expenses.py") elif ans=="4": print(" Goodbye") break elif ans !="": print(" Not Valid Choice Try again") ############################################## oldcity ~/MyPython $ python Basic-Menu.py 1.Add Expenses 2.View/Print Expenses 3.Verify Entries 4.Exit/Quit What would you like to do? 3 file line count : Choose file # 0 to Enter Choice 1 Enter Month to Verify [1-12]: 1 Jan FP&L 16.42 2 Jan PLAN-D 72.00 2 Jan AARP 186.63 2 Jan DRUGS 125.17 1 Jan WATER 16.32 2 Jan DIAZ 109.00 2 Jan CAR 50.60 2 Jan AT&T 124.73 2 # items: Month Expenses: paid cash > paid check > paid c card > Job done 1.Add Expenses 2.View/Print Expenses 3.Verify Entries 4.Exit/Quit What would you like to do? 4 Goodbye
############################################## #!/usr/bin/python3 # # Verify-Expenses.py # 10-18-18 3:00 pM # open('expenses-18', 'r') num_lines = sum(1 for line in open('expenses-18')) print ('\n') print ('file line count :'), num_lines print ('\n') # cls = 0 while cls < 22: cls+=1 print ('\n\n') col1 = 0 amt = 0 month_expenses = 0 total_expenses = 0 howp1 = 0 howp2 = 0 howp3 = 0 cnt = 0 # # # Tuple line_num = 0 dyears = [] with open('Expenses-YY', 'r') as exp_yrs: for line in exp_yrs: dfiles = line.strip(",") dfiles = dfiles.rstrip("\n") print (' '), line_num, (' '),dfiles dyears.append(dfiles,) line_num+=1 # # print ('\n\n Choose file # 0 to '),line_num - 1 fn = int(input('\n\n Enter Choice ')) print ('\n\n') datafile = (dyears[fn]) # vmm = input('\n\n Enter Month to Verify [1-12]: ') vmm = int(vmm) cls = 0 while cls < 22: cls+=1 print ('\n\n') print (' '),datafile print ('\n\n') # with open( datafile, 'r') as yrs_file: for line in yrs_file: (pdate,catg,amt,howp) = line.split(',') pdate = str(pdate) pdate = pdate.strip() pdate = str(pdate) length = len(pdate) catg = catg.strip() catg = int(catg) amt = amt.strip() amt = float(amt) howp = howp.strip() howp = int(howp) mm = pdate[0:2] mm = int(mm) if (vmm == mm): cnt = cnt + 1 month_expenses = month_expenses + amt howp = int(howp) month = int(mm) monthDict={1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'} monthIndex = month month = monthDict[monthIndex] mcatg = int(catg) mcatgDict={1:'AT&T ', 2:'FP&L ', 3:'WATER ', 4:'GAS ', 5:'PLAN-D', 6:'AARP ', 7:'DIAZ ', 8:'DRUGS ', 9:'HOUSE ', 10:'CAR ', 11:'MISC '} mcatgIndex = mcatg mcatg = mcatgDict[mcatgIndex] if howp == 1: howp1 = howp1 + 1 elif howp == 2: howp2 = howp2 + 1 elif howp == 3: howp3 = howp3 + 1 else: blank = 0 mnth_expenses = (" %s %s %6.2f %s" % (month,mcatg,amt,howp)) print (mnth_expenses) # print ('\n\n # items: '), cnt print (' Month Expenses: '), month_expenses print ('\n') print (' paid cash > '), howp1 print (' paid check > '), howp2 print (' paid c card > '), howp3 print ('\n \n') print ('Job done ')
############################################## oldcity ~/MyPython $ python Verify-Expenses.py file line count : 72 0 expenses-16 1 expenses-17 2 expenses-18 Choose file # 0 to 2 Enter Choice 1 Enter Month to Verify [1-12]: 1 expenses-17 Jan FP&L 16.42 2 Jan PLAN-D 72.00 2 Jan AARP 186.63 2 Jan DRUGS 125.17 1 Jan WATER 16.32 2 Jan DIAZ 109.00 2 Jan CAR 50.60 2 Jan AT&T 124.73 2 # items: 8 Month Expenses: 700.87 paid cash > 1 paid check > 7 paid c card > 0 Job done ##############################################