Using statsitics sourced from baseball-reference.com and provided in CSV format, cBaseball is a command-line tool that allows the user to conveniently view team-level baseball statistics. In addition to displaying these statistics in an easily-understood format, cBaseball also facilitates team comparison, generating a comparison summary across three categories: hitting, fielding, and pitching.
Linux: Ensure you have g++ and git installed. Windows: Ensure you have MinGW and git installed.
sudo apt update
sudo apt install git g++
git clone https://github.com/AB1775/cBaseball
cd cBaseball/
g++ -o cBaseball cBaseball.cpp
./cBaseball
- Download MinGW Installer from MinGW-w64.org
- Select 'gcc' for Installation
- Add MinGW to your PATH Environment Variable
- Download Git for Windows from git-scm.com
- Follow the installation instructions
git clone https://github.com/AB1775/cBaseball
cd cBaseball/
g++ -o cBaseball.exe cBaseball.cpp
.\cBaseball.exe
After compiling and running the executable, you will be presented with a menu-driven interface. Follow the on-screen prompts to navigate through the program.
Select a category from the 3 menu items displayed by entering the appropriate number associated with the category.
After selecting the desired category, you will be able to display league-wide stats, search for a specific team, or compare two teams. The "Display all Stats" option outputs the stats of all 30 MLB teams for the specified category in alphabetical order.
The "Search Team" option allows you to output the statistics of an individual team, presenting the user with a numbered list of all 30 MLB teams.
Similar to the "Search Team" menu, the "Compare Team Statistics" option presents the user with a numbered list of all 30 MLB teams. Rather than selecting a single team, the user will be prompted to select two teams. From here, the statistics of both teams will be displayed along with a comparison summary. An example of this summary is shown below:
[IMPORTANT] This program uses the Team Standard Batting, Team Standard Pitching, and Team Fielding files.
- Open https://www.baseball-reference.com/leagues/majors/2024.shtml
- Locate the "Team Standard Batting" header
- Hover over the "Share & Export" drop-down menu below the title header
- Select "Get Table as CSV (for Excel)
- Copy the contents of this file, beginning with the header line (Tm,#Bat,BatAge, etc.) and paste it in the "team_standard_batting24.csv" file, ensuring that the file's previous contents are replaced with the new data.
Follow this process to update "Team Standard Pitching" and "Team Fielding"
If you want to store the CSV files in a different directory or change the names of the CSV files, you need to update the file paths in the source code before compiling:
- Open FileHandling.h.
- Locate the variables that define the file paths for the statistics files under "File Variables."
- Update these paths to point to the new directory where your CSV files are stored and/or update the file names.
- Recompile the program to apply the changes.
- Data files provided by baseball-reference.com, provider of complete current and historical baseball stats
- Special thanks to the creators of the libraries and tools used in this project