def main(): arg_parser = argparse.ArgumentParser() arg_parser.add_argument('-w', '--workbook') args = arg_parser.parse_args() statements = glob.glob(DOCUMENTS_PATH) sp = StatementProcessor() all_transactions = [] for file in statements: raw_data = parser.from_file(file) raw_data = raw_data['content'] statement_type = sp.determine_statement_type(raw_data) if statement_type == 'savings': transactions = sp.extract_transactions_savings(raw_data) all_transactions.extend(transactions) elif statement_type == 'mastercard': transactions = sp.extract_transactions_mastercard(raw_data) all_transactions.extend(transactions) elif statement_type == 'checking': transactions = sp.extract_transactions_checking(raw_data) all_transactions.extend(transactions) ew = ExcelWriter(all_transactions, args.workbook) ew.write_to_file() print('done :)')
# 3. Get list of students in file list_of_students = [] student_list_start = datetime.datetime.now() for statement in list_of_statements: list_of_students.append(statement.statement_student) student_list_end = datetime.datetime.now() print("Time spent adding students to list: %s" % ( student_list_end - student_list_start)) # deleting duplicates duplicates_start = datetime.datetime.now() student_set = set(list_of_students) duplicates_end = datetime.datetime.now() print( "Time spent deleting duplicates: %s" % (duplicates_end - duplicates_start)) print student_set print len(student_set) # 4. Search for statements for each student total_search_start = datetime.datetime.now() for student in student_set: matches = StatementProcessor.search_for_statements_by_student( list_of_statements, student) # 5. Process information and prepare for uploading print('processing info') StatementProcessor.process_transactions(matches, student) total_search_end = datetime.datetime.now() print( "Total time spent searching: %s" % (total_search_end - total_search_start)) # 6. Upload Transaction
def upload_statements_to_server(self, students_list, statements_list, statement): for student in statements_list: if student in students_list: matches = StatementProcessor.search_for_statements_by_student(statement, student) StatementProcessor.process_transactions(matches, student)