Python code
Problem description
Write a program that will calculate and display statistics of Broadway shows where the data comes from a comma-separated values (CSV) file. We will use the reader function from the csv module as seen in class that places the data from the CSV file into a list that can then be processed. The CSV file that will be used for this exercise is called boardway.csv and can be downloaded below. The first line of the file contains the names for each type of data stored in the subsequent lines. Each of the remaining lines represents a week's worth of data for a specific Broadway show. The date range of the data is from 2010 to 2016. The CSV file contains more than 10,000 lines, so it is a fairly large dataset. We will not be using all of the data available, but rather we will be specifically interested in the following data items: month, year, name of show, attendance totals, revenue totals, and performance totals. For this exercise, the program should ask three things from the user: 1) what type of stats does the user want to view, 2) the name of the show of interest, and 3) the year of interest. The type of stats include attendance, revenue, and number of performances. Once this information is obtained, the program should calculate the stats for the show and year of interest. This will include stats that are separated by each month of the year and then at the end the sum of the totals of each of the months. Once the stats has been printed, the program should terminate.
As seen in class, after the reader function in the csv module has been called and the result stored in a variable, a loop can be used to iterate over the CSV object stored in that variable. Also, as seen in class, in one iteration of the loop, the loop variable will contain a list representing one of the lines of the CSV file, where each element of the list represents the data that was separated by commas. For example, consider the second line in the file: "3":1/3/2010":1":2010":A Little Night Music":Walter Kerrs:Musicar:7527":101":10315437112":8" The list that will be generated for this line will look something like the following. This represents one line in the CSV file.