Skip to content

This project provides scripts to look up MLB player IDs by their full name or by their MLBAM ID from a combined CSV file containing player information. If found, the following player ids will be displayed: MLBAM, Baseball Reference, Retrosheet, and FanGraphs.

Notifications You must be signed in to change notification settings

timothyf/mlb-player-lookup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

MLB Player Lookup

This project provides scripts to look up MLB player IDs by their full name or by their MLBAM ID from a combined CSV file containing player information. If found the following player ids will be displayed: MLBAM, Baseball Reference, Retrosheet, and FanGraphs.

Prerequisites

  • Python 3.x
  • pandas library

You can install the required library using pip:

pip install pandas

Usage

To look up a player by their full name, run the player_lookup.py script with the player's full name as an argument:

python scripts/player_lookup.py "Player Name"

To look up a player by their MLBAM ID, run the reverse_lookup.py script with the player's MLBAM ID as an argument:

python scripts/reverse_lookup.py <mlbam_id>

Example

python scripts/player_lookup.py "Riley Greene"

(MLBAM) mlbam_id: 682985
(Baseball-Reference) bref_id: greenri03
(Retrosheet) retro_id: greer003
(FanGraphs) fangraphs_id: 25976
python scripts/reverse_lookup.py 682985

First Name: Riley
Last Name: Greene
(MLBAM) mlbam_id: 682985
(Baseball-Reference) bref_id: greenri03
(Retrosheet) retro_id: greer003
(FanGraphs) fangraphs_id: 25976

Script Details

The scripts read the combined CSV file located at mlb-player-lookup/data/combined_people.csv. The player_lookup.py script looks up the player by their full name, while the reverse_lookup.py script looks up the player by their MLBAM ID. If the player is found, it prints their MLBAM, Baseball Reference, Retrosheet, and FanGraphs IDs. If the player is not found, it suggests possible matches based on the last name or ID.

Functions

  • lookup_player(full_name, csv_file_path):
    Looks up a player by their full name in the specified CSV file.
  • reverse_lookup(player_id, csv_file_path):
    Looks up a player by their player ID in the specified CSV file.

Command Line Arguments
player_name: Full name of the player to look up.
player_id: ID of the player to look up.

About

This project provides scripts to look up MLB player IDs by their full name or by their MLBAM ID from a combined CSV file containing player information. If found, the following player ids will be displayed: MLBAM, Baseball Reference, Retrosheet, and FanGraphs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages