def runRulesMode(arguments): """Determines which set is classified by the rule-based approach.""" setFilenames = {"training": SET_FILENAMES[0], "test": SET_FILENAMES[1], "validation": SET_FILENAMES[2],} duration = timeit(lambda: applyRules(setFilenames[arguments.set.lower()]), number=1), showDuration(duration)
f = open(rules.getPath()+'expenses.csv','a') writer = csv.writer(f) if (datetime.now().year != 2015): raise Exception("Update rental cost for the new year.") desc = sys.argv[1] month = int(sys.argv[2]) if (desc == 'Rent'): date = str(month)+"/01/2015" cost = 1243.38 elif (desc == 'PGE' or desc == 'EBMUD'): date = str(month)+"/"+str(calendar.monthrange(datetime.now().year,month)[1])+"/"+str(datetime.now().year) cost = float(sys.argv[3]) else: raise Exception("Invalid manual option.") rule = rules.applyRules(date,desc,cost,'none') if rule == 'none': print "Modify rules manually." sys.exit(1) writer.writerow([date,desc,cost,rule]) except Exception, e: print e print "Usage: ./manual.py [Rent|PGE|EBMUD] [mm] [cost]" sys.exit(1) f.close()
f = open(rules.getPath() + item) reader = csv.reader(f) except: print "not a valid CSV file" sys.exit(1) for list in reader: try: # chase credit card log if len(list) == 5 and list[0] == "Sale": cost = -1 * float(list[-1]) date = list[1] desc = list[3].replace("'", "") category = "none" if not any(i in desc for i in cardban): rule = rules.applyRules(date, desc, cost, category) if rule == "none": rule = modifyRules(desc) writer.writerow([date, desc, cost, rule]) # amazon purchases elif len(list) == 32 and list[5] == "Amazon.com" and list[12] != "1001" and list[13] != "x": date = list[0] desc = list[2].replace("'", "") cost = float(list[24][1:]) + float(list[25][1:]) category = list[3] rule = rules.applyRules(date, desc, cost, category) if rule == "none": rule = modifyRules(desc) writer.writerow([date, desc, cost, rule]) # chase checking acct elif len(list) == 8 and list[0] == "DEBIT" and not any(i in list[2] for i in chkban):