Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python program that reads in Baseball statistics for players on various teams from a CSV file and display statistical information for a specified

Write a Python program that reads in Baseball statistics for players on various teams from a CSV file and display statistical information for a specified player. You will allow the user to find a player and display his statistics.

The interface (interaction with the user) will be via the terminal (stdin, stdout). The user interface will have 3 stages:

List, in alphabetical order, all teams represented within the file.

Allow the user to choose (menu style) a team, and then display all players for that team

Allow the user to choose (menu style) a player and then display the full set of statistics for that player

You will, after some input (you decide), bring the user back to the main (team list) menu, which will also have a "quit" option.

Your program will read a file called sample.in , which contains the player statistics.

The following fields are included for each record, as follows:

player's last name

player's first name

player's team

player's position

number of at bats

number of base hits

number of doubles

number of triples

number of home runs

number of runs batted in (RBI)

batting average (3 decimal places, no leading zero)

Note that all fields within a record are separated by commas, and that no field actually contains a comma.

Sample.in

Alou,Moises,Mets,OF,328,112,19,1,13,49,.341 Hermedia,Jeremy,Marlins,OF,429,127,31,1,18,63,.296 Howard,Ryan,Phillies,1b,529,142,26,0,47,136,.268 Jacobs,Mike,Marlins,1b,426,113,27,2,17,54,.265 Johnson,Kelly,Braves,2b,521,144,26,0,16,68,.276 Kearns,Austin,Nationals,OF,587,156,35,1,16,74,.266 Renteria,Edgar,Braves,SS,494,164,30,1,12,57,.332 Reyes,Jose,Mets,SS,681,191,36,12,12,57,.280 Rollins,Jimmy,Phillies,SS,716,212,38,20,30,94,.296 

You will want to keep the keys (for both team and player lists) in a sorted list for displaying a menu (easy access). For storing statistical details, associating them with a player, associating players with teams, please think about how you would store this. Nice tables will drive a lot of the rest of your code.

You will probably choose to utilize some combination of Python's list and dictionary types (list of dictionaries, dictionaries of lists, ....)

You may parse the input file only once, so you need to store the information for easy retrieval.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago