Hole | Wins | Losses | Score | +1 |
---|---|---|---|---|
1 | 44 | 37 | +1 | (-2) |
10 | ||||
Avg | 44 | 37 | +33 |
Here is a Python code snippet that will parse the text and output a dictionary with game results:
import re
def parse_game_results(text):
games = {}
lines = text.split('\n')
for line in lines:
if line.startswith('September '):
day_month_year = line
day, month, year = map(int, re.findall(r'\d+', day_month_year))
if day == 25 and (month == 9 or (month == 10 and day > 22)):
break
for i in range(day + 1, len(lines)):
game_line = lines[i]
# Regular expression pattern to match the date of a baseball game
if re.match(r'\d{8}', game_line):
continue
match = re.search(r'(\d+)-(\d+): (\w+) \d+ - (\d+)-(\d+)', game_line)
if match:
home_team, score_home, day_home, month_home, year_home = match.groups()
away_team, score_away, day_away, month_away, year_away = None, None, None, None, None
# Get the score of the visiting team
for j in range(i + 1, len(lines)):
visit_line = lines[j]
if re.match(r'\d+)-\d+: \w+ \d+-\d+', visit_line):
visit_match = re.search(r'(\d+)-(\d+)', visit_line)
if visit_match:
day_visit, month_visit = visit_match.groups()
if (month_visit == month_home and
int(day_visit) < int(day_home)):
away_team = visit_match.group(0).split('-')[1]
score_away = visit_match.group(2)
day_away, month_away, year_away = map(int, re.findall(r'\d+', day_visit))
if (month_visit == month_home and
int(day_visit) > int(day_home)):
away_team = visit_match.group(0).split('-')[1]
score_away = visit_match.group(2)
day_away, month_away, year_away = map(int, re.findall(r'\d+', day_visit))
# Stop looking for the visiting team's score
if (month_visit == month_home and
int(day_visit) > int(day_home)):
break
home_score = int(score_home)
away_score = int(score_away)
games[(year, month, day)] = {'Home': f'{home_team} {home_score}', 'Away': f'{away_team} {away_score}'}
return games
text = """... (your original text here)"""
games_result = parse_game_results(text)
for year_month_day, result in games_result.items():
print(f"{year_month_day[0]}-{year_month_day[1]}-{year_month_day[2]}: {result}")
This code will output a dictionary with the game results for each date. The dates are ordered by day and month from earliest to latest. If two or more games have the same date, they are sorted alphabetically by home team.
Note that this code assumes that the text has been properly formatted and doesn't account for any potential errors in the input data. Updated: July 18, 2025 at 10:55 AM