Fixed critical bug where all outfielders were incorrectly assigned as DH due to defense CSV column mismatch in retrosheet_data.py: - Lines 889, 926: Changed column check from 'in row' to 'in pos_df.columns' to correctly detect bis_runs_total availability - Line 947: Fixed fallback from non-existent 'tz_runs_outfield' to 'tz_runs_total' which actually exists in Baseball Reference CSVs Impact: - Before: 57 DH players, 0 outfield positions - After: 3 DH players, 62 outfielders (23 RF, 20 CF, 19 LF) Added scripts/check_positions.sh: - Validates position distribution after card generation - Flags anomalous DH counts (>5 or >10%) - Verifies outfield positions exist in cardpositions table - Provides quick smoke test for defensive calculations Updated CLAUDE.md: - Added Position Validation section with check_positions.sh usage - Documented outfield position bug in Common Issues & Solutions - Included code examples and verification steps 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| legacy | ||
| add_second_cards.py | ||
| check_positions.sh | ||
| custom_card_creation.py | ||
| fix_pitcher_pos.py | ||
| position_updates.py | ||
| raw play tracking.py | ||
| README.md | ||
| rename_additional_defense_columns.py | ||
| rename_defense_columns.py | ||
| scouting_updates.py | ||
| supabase_doodling.py | ||
| test_retrosheet_integration.py | ||
| undo_po_rename.py | ||
| upload_scouting.py | ||
Scripts Directory
This directory contains utility scripts for Paper Dynasty card management and data operations.
Scripts
upload_scouting.py
Generates and uploads scouting reports to the remote server.
What it does:
- Runs
scouting_batters.pyto generate batting scouting reports - Runs
scouting_pitchers.pyto generate pitching scouting reports - Uploads all 4 CSV files (batting-basic, batting-ratings, pitching-basic, pitching-ratings) to sba-db server via SCP
How to run:
cd scripts
python upload_scouting.py
add_second_cards.py
Adds secondary card images (image2) to player records for players who have both batting and pitching cards.
What it does:
- Pulls all batting and pitching cards from the database
- For players missing their alternate card type in image2, adds the appropriate card URL
- Updates player records with the secondary card image
How to run:
python add_second_cards.py
custom_card_creation.py
Creates custom cardsets with specific configuration options.
What it does:
- Generates cards for a specified custom cardset
- Allows control over batting/pitching card generation
- Handles player position updates based on card data
- Uses command-line arguments for configuration
Arguments:
cardset_name: Name of the cardset to createseason: Season year (optional, defaults to first 4 chars of cardset name)player_description: Description shown on cards (optional)post_batters: Whether to post batting cards (default: true)post_pitchers: Whether to post pitching cards (default: true)post_players: Whether to post player updates (default: true)
How to run:
python custom_card_creation.py cardset_name="2024 Custom" season=2024
fix_pitcher_pos.py
Updates pitcher positions (SP/RP/CP) based on their pitching card ratings.
What it does:
- Queries all players with position P
- Checks their starter_rating and closer_rating from pitching cards
- Updates positions: SR >= 4 → SP, otherwise → RP, CR present → CP
How to run:
python fix_pitcher_pos.py
position_updates.py
Comprehensive player position updates for a specified cardset.
What it does:
- Updates all player positions based on their cards in a specific cardset
- Handles pitchers (SP/RP/CP logic based on ratings)
- Handles fielders (preserves existing positions)
- Only updates positions that have changed
Arguments:
cardset_name: Name of the cardset to updatepost_players: Whether to actually post updates (default: false)
How to run:
python position_updates.py cardset_name="2025 Live" post_players=true
scouting_updates.py
Triggers scouting report calculations on the Paper Dynasty API.
What it does:
- Runs 4 sequential API calls to calculate card ratings:
- Basic batting ratings
- Full batting scouting ratings
- Basic pitching ratings
- Full pitching scouting ratings
- Times each operation and reports total runtime
How to run:
python scouting_updates.py
supabase_doodling.py
Development/testing script for Supabase operations (not for production use).
raw play tracking.py
Legacy script (purpose unclear from filename - check contents before use).
Legacy Scripts
The legacy/ subdirectory contains older scripts that are no longer actively used but kept for reference.
Notes
- Most scripts require authentication credentials configured in
db_calls.py - Scripts typically use async/await patterns and should be run with
asyncio.run() - Check individual script headers for additional documentation
- Scripts in this directory should be run from the scripts directory or with appropriate path handling