Devil Rays Scorecard

Last Updated:
Devil Rays logo
HoleWinsLossesScore+18
12755+18(+4)
10
Avg2755+51

Analysis

This text appears to be a large block of plain text data in the CSV (Comma Separated Values) format.

To parse this data into a Python dictionary, I can use regular expressions and loop through each line.

Here's how you could do it:

import re
from collections import defaultdict

def convert_to_dict(csv_data):
    lines = csv_data.split('\n')
    teams_dict = defaultdict(lambda: {'Wins': 0, 'Losses': 0})
    
    for line in lines[1:]:
        line = line.strip()
        if not line:
            continue
        
        match = re.match(r'(\w+)\s+(\d{3}-\d{2})\s+([A-Z]+)\s+\((\d{3}-\d{2})\)', line)
        
        if match:
            team1, team1_wins, team1_loss, opponent = match.groups()
            teams_dict[team1]['Wins'] += int(team1_wins.split('-')[0])
            teams_dict[team1]['Losses'] += int(opponent.split('-')[0])
            
            if len(match.groups()) > 4:
                team2, team2_wins, team2_loss, opponent = match.groups()[3:]
                teams_dict[team2]['Wins'] += int(team2_wins.split('-')[0])
                teams_dict[team2]['Losses'] += int(opponent.split('-')[0])
            
            if len(match.groups()) > 5:
                result = match.group(4).split('-')
                if result[1] == 'L' or (result[0].isdigit() and result[1].isalpha()):
                    teams_dict[opponent]['Wins'] += int(result[0])
                    teams_dict[opponent]['Losses'] += 1
                else:
                    teams_dict[result[0]]['Wins'] += int(result[1])
                    teams_dict[result[0]]['Losses'] += 1
    
    return teams_dict

csv_data = """...

Note that the code is quite simplified and only considers wins/loss in one case. The team2, opponent values in case of more than two games are added to dictionary like this: teams_dict[team2]['Wins'] += int(team2_wins.split('-')[0]).

Also, note that this script might not cover all edge cases or possible input formats. You may need to adjust it according to your needs.

Here's an example of how you can use the function:

csv_data = """...your data here...

teams_dict = convert_to_dict(csv_data)
for team_name in teams_dict:
    print(f"Team: {team_name}, Wins: {teams_dict[team_name]['Wins']}, Losses: {teams_dict[team_name]['Losses']}")

And the last result is printed out. Updated: June 26, 2025 at 8:56 PM