def start_main(): data = common_lib.open_file(common_lib.NBA_STANDING_HTML_FILE) data = get_all_expanded_standings(data) while data.find('<a href="/teams/') > 0: data = parse_data_get_true_pct(data) ######################### # while data.find('<td class="team">') > 0: # data = parse_html_file(data) ######################### thisList = common_lib.convert_list_into_str(list_of_team_stats.listOfTeamStats) common_lib.write_file(thisList, common_lib.NBA_STANDING_CSV_FILE)
def start_main(): data = common_lib.open_file(common_lib.NBA_STANDING_HTML_FILE) data = get_all_expanded_standings(data) while data.find('<a href="/teams/') > 0: data = parse_data_get_true_pct(data) ######################### # while data.find('<td class="team">') > 0: # data = parse_html_file(data) ######################### thisList = common_lib.convert_list_into_str( list_of_team_stats.listOfTeamStats) common_lib.write_file(thisList, common_lib.NBA_STANDING_CSV_FILE)
def start_main(): cleanup() finalList = [] teamList = common_lib.get_multiple_col(NBA_POWER_RANKING_CSV_FILE, 0) leadingTeamsTuple = get_two_leading_teams_of_true_power_ranking(teamList) leadingTeam = leadingTeamsTuple[0] secondLeadingTeam = leadingTeamsTuple[1] championTeam = get_team_champion_from_html(common_lib.NBA_CHAMPION_HTML_FILE) finalsRunnerUpTeam = get_team_finals_runner_up_from_html(common_lib.NBA_CHAMPION_HTML_FILE) # Check if file exist. data = common_lib.open_file(common_lib.NBA_LEADING_TEAM_CHAMPION_CHECK_CSV_FILE) if data == 'FileNotFoundError': finalList.append(['YEAR', 'TRUE_POWER_RANK_LEAD_TEAM', 'TRUE_POWER_RANK_SECOND_LEAD_TEAM', 'CHAMPION_TEAM', 'FINALS_RUNNER_UP_TEAM', 'SAME?']) # if the program cannot find a championTeam, then print 'No Champion'. if not championTeam: championTeam = 'No Champion' if not finalsRunnerUpTeam: finalsRunnerUpTeam = 'No Runner Up' # Check if leadingTeam is the same as championTeam leadingTeam = change_element_into_str(leadingTeam) secondLeadingTeam = change_element_into_str(secondLeadingTeam) if leadingTeam.lower() == championTeam.lower(): sameTeam = True elif leadingTeam.lower() == finalsRunnerUpTeam.lower(): sameTeam = True elif secondLeadingTeam.lower() == championTeam.lower(): sameTeam = True elif secondLeadingTeam.lower() == finalsRunnerUpTeam.lower(): sameTeam = True else: sameTeam = False finalList.append([YEAR, leadingTeam, secondLeadingTeam, championTeam, finalsRunnerUpTeam, sameTeam]) dataStr = common_lib.convert_list_into_str(finalList) dataStr = dataStr + '\n' common_lib.append_file(dataStr, common_lib.NBA_LEADING_TEAM_CHAMPION_CHECK_CSV_FILE)
def start_main(): list2 = [] finalList = [] theList = common_lib.get_multiple_col(NBA_POWER_RANKING_CSV_FILE, 0, 1, 2, 3, 4) i = 0 while i < len(theList): teamName = common_lib.parse_the_popped_element_to_return_str( theList.pop()) roadWin = common_lib.parse_the_popped_element_to_return_str( theList.pop()) homeLoss = common_lib.parse_the_popped_element_to_return_str( theList.pop()) pct = common_lib.parse_the_popped_element_to_return_str(theList.pop()) truePct = common_lib.parse_the_popped_element_to_return_str( theList.pop()) list2.append([teamName, roadWin, homeLoss, pct, truePct]) # Add column 'PCT_GAP', 'TIER', and 'LABEL' onto header list2.reverse() header = list2.pop() header.append('PCT_GAP') header.append('TIER') header.append('LABEL') header.append('PROJECTION') finalList.append(header) # Evaluates team's TRUE_PCT to find PCT_GAP, TIER, and LABEL # Set initial values up for looping length = len(list2) tier = 0 letterTier = chr( tier + ord('A')) # Converts the int to corresponding english alphabet labelProjeTuple = assign_label_and_projection_to_tier(letterTier) element1 = list2.pop() element1.append('0') element1.append(str(letterTier)) element1.append(str(labelProjeTuple[0])) element1.append(str(labelProjeTuple[1])) list2.append(element1) for i in range(length): # for i in range(0,1): try: # Grab two elements from the list element1 = list2.pop() element2 = list2.pop() except IndexError: finalList.append(element2) break else: # Get PCT_GAP floatTruePct1 = float(element1[4]) floatTruePct2 = float(element2[4]) pctGap = (floatTruePct1 / floatTruePct2) - 1 # Get TIER if pctGap > PCT_GAP_CUTOFF: tier += 1 letterTier = chr(tier + ord('A')) # Assign LABEL to corresponding TIER labelProjeTuple = assign_label_and_projection_to_tier(letterTier) element2.append(str(pctGap)) element2.append(str(letterTier)) element2.append(str(labelProjeTuple[0])) element2.append(str(labelProjeTuple[1])) finalList.append(element1) list2.append(element2) finalList = common_lib.convert_list_into_str(finalList) common_lib.write_file(finalList, NBA_POWER_RANKING_CSV_FILE)
def start_main(): list2 = [] finalList = [] theList = common_lib.get_multiple_col(NBA_POWER_RANKING_CSV_FILE, 0,1,2,3,4) i = 0 while i < len(theList): teamName = common_lib.parse_the_popped_element_to_return_str(theList.pop()) roadWin = common_lib.parse_the_popped_element_to_return_str(theList.pop()) homeLoss = common_lib.parse_the_popped_element_to_return_str(theList.pop()) pct = common_lib.parse_the_popped_element_to_return_str(theList.pop()) truePct = common_lib.parse_the_popped_element_to_return_str(theList.pop()) list2.append([teamName, roadWin, homeLoss, pct, truePct]) # Add column 'PCT_GAP', 'TIER', and 'LABEL' onto header list2.reverse() header = list2.pop() header.append('PCT_GAP') header.append('TIER') header.append('LABEL') header.append('PROJECTION') finalList.append(header) # Evaluates team's TRUE_PCT to find PCT_GAP, TIER, and LABEL # Set initial values up for looping length = len(list2) tier = 0 letterTier = chr(tier + ord('A')) # Converts the int to corresponding english alphabet labelProjeTuple = assign_label_and_projection_to_tier(letterTier) element1 = list2.pop() element1.append('0') element1.append(str(letterTier)) element1.append(str(labelProjeTuple[0])) element1.append(str(labelProjeTuple[1])) list2.append(element1) for i in range(length): # for i in range(0,1): try: # Grab two elements from the list element1 = list2.pop() element2 = list2.pop() except IndexError: finalList.append(element2) break else: # Get PCT_GAP floatTruePct1 = float(element1[4]) floatTruePct2 = float(element2[4]) pctGap = (floatTruePct1 / floatTruePct2) - 1 # Get TIER if pctGap > PCT_GAP_CUTOFF: tier += 1 letterTier = chr(tier + ord('A')) # Assign LABEL to corresponding TIER labelProjeTuple = assign_label_and_projection_to_tier(letterTier) element2.append(str(pctGap)) element2.append(str(letterTier)) element2.append(str(labelProjeTuple[0])) element2.append(str(labelProjeTuple[1])) finalList.append(element1) list2.append(element2) finalList = common_lib.convert_list_into_str(finalList) common_lib.write_file(finalList, NBA_POWER_RANKING_CSV_FILE)
def start_main(): tmpList = sort_true_pct_ranking() tmpList = common_lib.convert_list_into_str(tmpList) common_lib.write_file(tmpList, NBA_POWER_RANKING_CSV_FILE)