""" Test script to verify retrosheet_data.py works with the new transformer. """ import sys import logging from retrosheet_data import ( get_base_batting_df, get_base_pitching_df, RETRO_FILE_PATH, EVENTS_FILENAME, ) # Set up logging logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) print(f"\n{'='*60}") print("Testing Retrosheet Data Integration") print(f"{'='*60}\n") file_path = f"{RETRO_FILE_PATH}{EVENTS_FILENAME}" print(f"Loading from: {file_path}") # Test date range (full 2005 season) start_date = 20050403 # Opening Day 2005 end_date = 20051003 # End of 2005 regular season print("\nTest 1: Loading Batting Data") print(f"Date range: {start_date} to {end_date}") try: all_plays_batting, batting_stats = get_base_batting_df( file_path, start_date, end_date ) print("✓ Success!") print(f" - Total plays loaded: {len(all_plays_batting)}") print(f" - Qualified batters: {len(batting_stats)}") print("\nSample batting stats:") print(batting_stats.head(3)) except Exception as e: print(f"✗ Failed: {e}") sys.exit(1) print(f"\n{'-'*60}\n") print("Test 2: Loading Pitching Data") try: all_plays_pitching, pitching_stats = get_base_pitching_df( file_path, start_date, end_date ) print("✓ Success!") print(f" - Total plays loaded: {len(all_plays_pitching)}") print(f" - Qualified pitchers: {len(pitching_stats)}") print("\nSample pitching stats:") print(pitching_stats.head(3)) except Exception as e: print(f"✗ Failed: {e}") sys.exit(1) print(f"\n{'='*60}") print("All tests passed! ✓") print(f"{'='*60}\n")