i am completely stumped at how to create this program. can anyone help out? here are the guidelines.

Introduction

Perhaps in no other sport does statistics play as major a role as in the game of Baseball. In fact, certain numbers, such as 56 (length of Joe DiMaggio's hitting streak), 73 (Barry Bonds' single season home run record) and 755 (Hank Aaron's career home run record) are part of American sports culture.

You will write a Python program that reads in Baseball statistics for players on various teams from a CSV (comma separated value) file and display statistical information for a specified player. You will allow the user to find a player and display his statistics.
The interface

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

1. List, in alphabetical order, all teams represented within the file.
2. Allow the user to choose (menu style) a team, and then display all players for that team
3. 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.

When you list out the teams or players, enumerate them, so that the user can choose by entering a number; don't make the user type out text (team or player names), etc.
Input

Player statistics input are provided in sample.in

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

1. player's last name
2. player's first name
3. player's team
4. player's position
5. number of at bats
6. number of base hits
7. number of doubles
8. number of triples
9. number of home runs
10. number of runs batted in (RBI)
11. 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.

Please review some of the Python examples from week 4 which demonstrate how to retrieve files (either entire file or line by line) into Python. Also, these examples demonstrate how to parse the line items into individual fields.
Notes, the data structures

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.

------------------------------------------------------------------------------------------------------------------

Here is the contents of the .csv file

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
Utley,Chase,Phillies,2b,530,176,48,5,22,103,.332
Victorino,Shane,Phillies,OF,456,128,23,3,12,46,.281
Young,Dmitri,Nationals,1b,460,147,38,1,13,74,.320
Zimmerman,Ryan,Nationals,3b,653,174,45,3,24,91,.266

------------------------------------------------------------------------------------------------------------------

if anyone could help me out that would be appreciated, thank you.

You'd want to start by getting the info from the file.

allplayerinfo = []
info = open("filename.cvs")
data = info.read()
info.close()

for lines in data:
    allplayerinfo.append(lines)

Then you should sort the info for every player. Use .split(",") on each individual string line. Organize them all into var lists. Or sort them and .join(" - ") or w/e your teacher wants.

Well, I would recommend checking out the csv module

import csv
help(csv)

in the Python docs. It can do what Shadow is recommending pretty much automatically.

I would also recommend getting your menu working first, just as a stub. The options don't have to do anything, but if you have the working menu framework going, then you can add functionality and test it as you go.

Jeff

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.