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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education