For this exercise you are going to write a program that will allow you to accept and load different temperature files that are for a specific month in the United States for a period of 1895 - 2016 that have a .csv format. Once the data is loaded, write a program that will calculate the average of all the numbers stored in the file and find the maximum and minimum values. Additionally the program will handle the following errors when trying to load the file: • It should handle IOError exceptions that are raised when the file is opened and data is read from it by printing "Trouble opening file. Try again." and provide you with another opportunity to load the file. • It should handle any ValueError exceptions that are raised when the items that are read from the file are converted to a number by printing "File must have only numbers. Try again."
For this exercise you are going to write a program that will allow you to accept and load different temperature files that are for a specific month in the United States for a period of 1895 - 2016 that have a .csv format. Once the data is loaded, write a program that will calculate the average of all the numbers stored in the file and find the maximum and minimum values. Additionally the program will handle the following errors when trying to load the file: • It should handle IOError exceptions that are raised when the file is opened and data is read from it by printing "Trouble opening file. Try again." and provide you with another opportunity to load the file. • It should handle any ValueError exceptions that are raised when the items that are read from the file are converted to a number by printing "File must have only numbers. Try again."
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
Related questions
Question
![For this exercise you are going to write a program that will allow you to accept
and load different temperature files that are for a specific month in the United
States for a period of 1895 - 2016 that have a .csv format. Once the data is
loaded, write a program that will calculate the average of all the numbers
stored in the file and find the maximum and minimum values. Additionally the
program will handle the following errors when trying to load the file: • It should
handle IOError exceptions that are raised when the file is opened and data is
read from it by printing "Trouble opening file. Try again." and provide you with
another opportunity to load the file. • It should handle any ValueError
exceptions that are raised when the items that are read from the file are
converted to a number by printing "File must have only numbers. Try again."
and provide you with another opportunity to load the file. The program should
not abort from these errors, but allow you to attempt to load a valid file. You
should be able to enter S to stop trying to load files. 1) Prompt the user for file
name(e.g., "Please enter the name of the file (S to stop):") 2) If the user enters S
print bye 3) If there is an IOError exception print ("Trouble opening file. Try
Again") 4) If the file exists a) Try to sum all the number and determine the count
of numbers in the file b) Try to determine the maximum and minimum number
in the file c) If an IOError occurs print ('An error occurred trying to read the file.')
and return to file load prompt (use except) d) If an ValueError occurs print("File
must have only numbers. Try again.") and return to file load prompt(use except)
e) If any other Error occurs print("An error has occurred") and return to file load
prompt(use except) f) If no errors occur calculate the mean 5) Print the mean,
min and maximum temperatures in the file and the file name in a nicely
formatted statement. The output should look similar to: The mean temperature
is: 33.8. The minimum temperature was 25.2. The maximum temperature was
41.4. From file FebTemp Please enter the name of the file (S to stop): 6) Your
program must contain an main function and properly call the main function 7)
Appropriately comment your code. 8) Run the program with the following test
cases. a) Just hit a carriage return - Note: should produce the message -
Trouble opening file. Try again. b) FebTempBad.csv c) FebTemp.csv d)
MarTemp.csv](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F12f76409-ad47-49ac-a9c1-6e134acaa2ad%2F90d360af-0d10-495f-a25f-d618be696709%2Ft4cyqgs_processed.jpeg&w=3840&q=75)
Transcribed Image Text:For this exercise you are going to write a program that will allow you to accept
and load different temperature files that are for a specific month in the United
States for a period of 1895 - 2016 that have a .csv format. Once the data is
loaded, write a program that will calculate the average of all the numbers
stored in the file and find the maximum and minimum values. Additionally the
program will handle the following errors when trying to load the file: • It should
handle IOError exceptions that are raised when the file is opened and data is
read from it by printing "Trouble opening file. Try again." and provide you with
another opportunity to load the file. • It should handle any ValueError
exceptions that are raised when the items that are read from the file are
converted to a number by printing "File must have only numbers. Try again."
and provide you with another opportunity to load the file. The program should
not abort from these errors, but allow you to attempt to load a valid file. You
should be able to enter S to stop trying to load files. 1) Prompt the user for file
name(e.g., "Please enter the name of the file (S to stop):") 2) If the user enters S
print bye 3) If there is an IOError exception print ("Trouble opening file. Try
Again") 4) If the file exists a) Try to sum all the number and determine the count
of numbers in the file b) Try to determine the maximum and minimum number
in the file c) If an IOError occurs print ('An error occurred trying to read the file.')
and return to file load prompt (use except) d) If an ValueError occurs print("File
must have only numbers. Try again.") and return to file load prompt(use except)
e) If any other Error occurs print("An error has occurred") and return to file load
prompt(use except) f) If no errors occur calculate the mean 5) Print the mean,
min and maximum temperatures in the file and the file name in a nicely
formatted statement. The output should look similar to: The mean temperature
is: 33.8. The minimum temperature was 25.2. The maximum temperature was
41.4. From file FebTemp Please enter the name of the file (S to stop): 6) Your
program must contain an main function and properly call the main function 7)
Appropriately comment your code. 8) Run the program with the following test
cases. a) Just hit a carriage return - Note: should produce the message -
Trouble opening file. Try again. b) FebTempBad.csv c) FebTemp.csv d)
MarTemp.csv
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education