Import the CSV module and read the file colleges.csv Process the data from the file for the following: Store the date column in a variable so you can adjust the formatting to be MM/DD/YYYY or YYYY Use the cases_2021 column as the value to decide which sentence option to display Use the county column to determine which school is in Los Angeles county

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.4: Arrays As Arguments
Problem 7E: (Statistics) Write a program that includes two functions named calcavg() and variance(). The...
icon
Related questions
Question
  1. Import the CSV module and read the file colleges.csv
  2. Process the data from the file for the following:
    • Store the date column in a variable so you can adjust the formatting to be MM/DD/YYYY or YYYY
    • Use the cases_2021 column as the value to decide which sentence option to display
    • Use the county column to determine which school is in Los Angeles county
  3. If the school is in Los Angeles county, output the sentence one of the following example sentences based on the available data as a single string:
    • As of MM/DD/YYYY, COLLEGE NAME reported YY cases of COVID-19 in YYYY.
    • As of MM/DD/YYYY, COLLEGE NAME reported no cases of COVID-19 in YYYY.
  4. The sentence in the print() statement should be a single string statement, no commas seperating values
  5. Some values in the CSV may be modified from the original to ensure you are correctly parsing the data as requested.

colleges.csv
date,state,county,city,ipeds_id,college,cases,cases_2021,notes
2021-05-26,California,Orange,Fullerton,110565,"California State University, Fullerton",45,23,
2021-05-26,California,Los Angeles,Long Beach,110583,"California State University, Long Beach",163,64,
2021-05-26,California,Los Angeles,Los Angeles,110592,"California State University, Los Angeles",199,,
2021-05-26,California,Monterey,Marina,409698,"California State University, Monterey Bay",18,8,
2021-05-26,California,Los Angeles,Los Angeles,110608,"California State University, Northridge",149,55,
2021-05-26,California,Sacramento,Sacramento,110617,"California State University, Sacramento",148,46,
2021-05-26,California,San Bernardino,San Bernardino,110510,"California State University, San Bernardino",43,15,
2021-05-26,California,San Diego,San Marcos,366711,"California State University, San Marcos",118,37,
2021-05-26,California,Stanislaus,Turlock,110495,"California State University, Stanislaus",39,19,
2021-05-26,California,Orange,Orange,111948,Chapman University,377,225,
2020-12-31,California,Los Angeles,Claremont,112260,Claremont McKenna College,0,,
2021-05-26,California,Orange,Irvine,112075,Concordia University Irvine,82,59,
2021-05-26,California,Orange,Cypress,113236,Cypress College,20,1,
2021-05-26,California,Marin,San Rafael,113698,Dominican University of California,32,24,
2021-05-26,California,Los Angeles,Torrance,113980,El Camino Community College,35,16,

Output:

As of 05/26/2021, California State University, Long Beach reported 163 cases of COVID-19 in 2021.

As of 05/26/2021, California State University, Los Angeles reported no cases of COVID-19 in 2021.

As of 05/26/2021, California State University, Northridge reported 149 cases of COVID-19 in 2021.

Code attempt:

import csv

def main():
    with open("colleges.csv", "r") as csv_file:
        csv_reader = csv.reader(csv_file) 
        date = ("date".format('%m/%d/%Y')
        cases_2021 = "cases"
        county = "Los Angeles"
        college = "college"
        yyyy = "2021"
        
        if cases reported = yy
            return yy
        else:
            return reported no cases
            
        
        for row in csv_reader:
            print("As of" + date, college, "reported of covid19 in " + yyyy)

 

# DO NOT MODIFY BELOW
if __name__ == "__main__":
    # Call Main Program
    main()

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

How do you change the date from mm/dd/yyyy to dd/mm/yyyy?

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage