Hi, I've attached the directions for this project and the code that I have begun for it. I have done about 1/3 of the project with the first 3 functions complete and passing the tests. I need help with the last functions. I have also attached a test file that is used for the assignment.
ID,Name,Sex,Age,Height,Weight,Team,NOC,Games,Year,Season,City,Sport,Event,Medal 1,Imen Zaabar,F,15,155,44,Tunisia,TUN,1996 Summer,1996,Summer,Atlanta,Gymnastics,Gymnastics Women's Uneven Bars,Gold 4,Edgar Lindenau Aabye,M,34,NA,NA,Denmark/Sweden,DEN,1900 Summer,1900,Summer,Paris,Tug-Of-War,Tug-Of-War Men's Tug-Of-War,Gold 15,Arvo Ossian Aaltonen,M,30,NA,NA,Finland,FIN,1920 Summer,1920,Summer,Antwerpen,Swimming,Swimming Men's 200 metres Breaststroke,Bronze 15,Arvo Ossian Aaltonen,M,30,NA,NA,Finland,FIN,1920 Summer,1920,Summer,Antwerpen,Swimming,Swimming Men's 400 metres Breaststroke,Bronze 16,Juhamatti Tapio Aaltonen,M,28,184,85,Finland,FIN,2014 Winter,2014,Winter,Sochi,Ice Hockey,Ice Hockey Men's Ice Hockey,Bronze 17,Paavo Johannes Aaltonen,M,28,175,64,Finland,FIN,1948 Summer,1948,Summer,London,Gymnastics,Gymnastics Men's Individual All-Around,Bronze 17,Paavo Johannes Aaltonen,M,28,175,64,Finland,FIN,1948 Summer,1948,Summer,London,Gymnastics,Gymnastics Men's Team All-Around,Gold 17,Paavo Johannes Aaltonen,M,28,175,64,Finland,FIN,1948 Summer,1948,Summer,London,Gymnastics,Gymnastics Men's Horse Vault,Gold 17,Paavo Johannes Aaltonen,M,28,175,64,Finland,FIN,1948 Summer,1948,Summer,London,Gymnastics,Gymnastics Men's Pommelled Horse,Gold 17,Paavo Johannes Aaltonen,M,32,175,64,Finland,FIN,1952 Summer,1952,Summer,Helsinki,Gymnastics,Gymnastics Men's Team All-Around,Bronze 20,Kjetil Andr Aamodt,M,20,176,85,Norway,NOR,1992 Winter,1992,Winter,Albertville,Alpine Skiing,Alpine Skiing Men's Super G,Gold 20,Kjetil Andr Aamodt,M,20,176,85,Norway,NOR,1992 Winter,1992,Winter,Albertville,Alpine Skiing,Alpine Skiing Men's Giant Slalom,Bronze 20,Kjetil Andr Aamodt,M,22,176,85,Norway,NOR,1994 Winter,1994,Winter,Lillehammer,Alpine Skiing,Alpine Skiing Men's Downhill,Silver 20,Kjetil Andr Aamodt,M,22,176,85,Norway,NOR,1994 Winter,1994,Winter,Lillehammer,Alpine Skiing,Alpine Skiing Men's Super G,Bronze 20,Kjetil Andr Aamodt,M,22,176,85,Norway,NOR,1994 Winter,1994,Winter,Lillehammer,Alpine Skiing,Alpine Skiing Men's Combined,Silver 20,Kjetil Andr Aamodt,M,30,176,85,Norway,NOR,2002 Winter,2002,Winter,Salt Lake City,Alpine Skiing,Alpine Skiing Men's Super G,Gold 20,Kjetil Andr Aamodt,M,30,176,85,Norway,NOR,2002 Winter,2002,Winter,Salt Lake City,Alpine Skiing,Alpine Skiing Men's Combined,Gold 20,Kjetil Andr Aamodt,M,34,176,85,Norway,NOR,2006 Winter,2006,Winter,Torino,Alpine Skiing,Alpine Skiing Men's Super G,Gold 21,Ragnhild Margrethe Aamodt,F,27,163,NA,Norway,NOR,2008 Summer,2008,Summer,Beijing,Handball,Handball Women's Handball,Gold 25,Alf Lied Aanning,M,24,NA,NA,Norway,NOR,1920 Summer,1920,Summer,Antwerpen,Gymnastics,Gymnastics Men's Team All-Around Free System,Silver 29,Willemien Aardenburg,F,22,NA,NA,Netherlands,NED,1988 Summer,1988,Summer,Seoul,Hockey,Hockey Women's Hockey,Bronze 30,Pepijn Aardewijn,M,26,189,72,Netherlands,NED,1996 Summer,1996,Summer,Atlanta,Rowing,Rowing Men's Lightweight Double Sculls,Silver 37,Ann Kristin Aarnes,F,23,182,64,Norway,NOR,1996 Summer,1996,Summer,Atlanta,Football,Football Women's Football,Bronze 38,Karl Jan Aas,M,20,NA,NA,Norway,NOR,1920 Summer,1920,Summer,Antwerpen,Gymnastics,Gymnastics Men's Team All-Around Free System,Silver CSE 231 Spring 2019 Edited 03/13/2019: to diplay the best athletes per sport, the table should be sorted by sport alphabetically and by medal counts in descending order. Test 5 was reduced to one plot instead of 2 plots. Programming Project 08 This assignment is worth 50 points (5.0% of the course grade) and must be completed and turned in before 11:59 on Monday, April 1, 2019. Assignment Overview • Dictionaries • Lists and tuples Assignment Background The Olympics happen every 2 years alternating between the summer and winter, where athletes from all over the world come to compete in a variety of sports and events. For this project, you will create a program that will analyze Olympics data over the years about athlete and country information. We’ll be going through the athletes_events.csv file to compare the best athletes in each sport and the top countries for specific sports. Afterwards, we’re going to plot the count of medals over the years for a specific country. Project Specifications You must implement the following functions: a) open_file(): This function prompts the user for the file name as input. It will try to open the file and return the file pointer. If the file is not found, the function must continue asking the user for a file name until the file can be opened and returned. b) get_athlete_stats(
): This function takes in the file pointer as input and skips over the header line. It will iterate through each line in the file and build a dictionary from the data. - Each column in line is separated by commas (since the file is a comma-separated values file). - name, gender, age, height, weight and country_code (column NOC) must be found. - Because of some entries you need to import csv # at the top of your program # in this function reader = csv.reader(fp) # the name “reader” on the left can be any name next(reader,None) # skips one header line, repeat if more header lines for line_list in reader: # reader returns a list - For each line in the file, you need to read the following: name = line_list[1] gender = line_list[2] age = int(line_list[3]) height = int(line_list[4]) weight = int(line_list[5]) CSE 231 Spring 2019 country_code = line_list[7] - All variables must be not null (cannot have ‘NA’ as its value) so ignore any lines without all valid values. (Hint: try-except is one way to do this. Also, “continue” is your friend.) - age, height and weight must be able to be converted to integers. - The dictionary will have the athlete name as its key and a list of tuples as its value. - An athlete can be in the Olympics multiple times and in multiple events so there are multiple entries for athletes, resulting in multiple tuples in lists. - This function will return the dictionary created. - A tuple in the list will have (gender, age, height, weight, country_code) as its content. c) get_country_stats(,