CSV Processor

CSV Image

In this short PA, you will be writing a program that reads in a CSV file with no column labels, and can compute an average (and maximum and min if you do the extra credit). Name the program csv_processor.py. Your program should ask the user for three input values:

Below, and example is show of the program accepting these three values from the user.

Enter CSV file name:
numbers.csv
Enter column number:
1
Enter column operation:
avg

After getting all of this information from the user, your program should do the following:

Walk Through

Let’s walk through an example. Let’s say that you requested your program to operate on numbers.csv, and it had the below contents:

1.5,2.0,3.0
8.0,5.0,7.0
3.0,2.0,2.0
2.0,2.0,2.0

That CSV file has four rows and three columns. You should store all of the values into a 2D list. Now, say that the user requested the avg (average) calculation on column 2. The code should loop through the rows of the 2D list, sum up the numeric values, and then calculate the average value. It should print:

The average for column 2 is: 2.75

The min of column 2 would be 2.0 and the max would be 5.0.

Complete Examples

Below are three complete examples. These examples use a file named numbers.txt with the same contents shown earlier. You can also use Gradescope to test your program.

Enter CSV file name:
numbers.csv
Enter column number:
1
Enter column operation:
avg
The average for column 1 is: 3.625
Enter CSV file name:
numbers.csv
Enter column number:
1
Enter column operation:
min
The minimum value in column 1 is: 1.5
Enter CSV file name:
numbers.csv
Enter column number:
2
Enter column operation:
max
The maximum value in column 2 is: 5.0

Recall that implementing min will count as extra credit! You are not required to implement them.

Submission

Submit to Gradescope by November 14th by 6pm. There will be some Gradescope test cases for avg. There will also be test cases for max and min, which will count as extra credit.