Hole | Wins | Losses | Score | +20 |
---|---|---|---|---|
1 | 35 | 46 | +10 | (+2) |
10 | 35 | 46 | +20 | (+2) |
Avg | 35 | 46 | +42 |
Based on the provided text, I will create a Python script to parse and analyze the baseball game data.
import re
from collections import defaultdict
class BaseballGameData:
def __init__(self):
self.teams = {}
self.games = []
def parse_data(self, data):
lines = data.split('\n')
team_name = None
for line in lines:
match = re.match(r'([A-Z]+) (.*)', line)
if match:
team_name = match.group(1)
elif team_name:
self.teams[team_name] = {'wins': 0, 'losses': 0}
game_info = {}
for part in line.split(' - '):
date_match = re.match(r'(\d{4}-\d{2}-\d{2})', part)
if date_match:
date = date_match.group(1)
score_match = re.match(r'(\d+)-(\d+)', part)
if score_match:
score = f"{score_match.group(1)}-{score_match.group(2)}"
game_info['date'] = date
game_info['score'] = score
else:
match = re.match(r'\d+ (wins|losses):', part)
if match:
value = int(match.group(1))
key = match.group(2)
if key == 'wins':
self.teams[team_name]['wins'] += value
elif key == 'losses':
self.teams[team_name]['losses'] += value
game_info['teams'] = list(self.teams.keys())
self.games.append(game_info)
def print_games(self):
for i, game in enumerate(self.games):
print(f"Game {i+1}:")
print(f"Date: {game['date']}")
print(f"Score: {game['score']}")
print("Teams:")
for team in game['teams']:
if self.teams[team]['wins'] > 0:
print(f"{team} (W-{self.teams[team]['wins']}-{self.teams[team]['losses']})")
else:
print(team)
print()
print("Team Records:")
for team, record in self.teams.items():
print(f"{team}: {record['wins']} - {record['losses']}")
game_data = BaseballGameData()
game_data.parse_data(text)
game_data.print_games()
This script defines a class BaseballGameData
that stores the data in a dictionary-like structure. The parse_data
method splits the input text into individual lines and extracts team names, scores, and wins/losses information using regular expressions. The print_games
method prints out the game details, including scores and team records.
Note: This is a simplified version of the script. You may need to adjust it according to your specific requirements and the format of the input data. Updated: July 1, 2025 at 10:31 PM