Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this question you must process files containing lines of comma-separated values. The first value in each line is a date in ISO 8601

student submitted image, transcription available belowstudent submitted image, transcription available below


 
 

In this question you must process files containing lines of comma-separated values. The first value in each line is a date in ISO 8601 format, for example 2010-01-01. The remaining one or more values in the line are floating point numbers, which might represent measurements of some physical quantity such as rainfall or windspeed. For example a simple 2-line data file might be 2010-01-01, 10.00, 20.0 2010-01-02,12.00, 100.1,3.2 You are to write a function print_daily_totals (filename) that takes the name of such a file as a parameter and reads the data from the file, printing the total of the readings for each day in the format given below. For each line in the input file you should print an output line in the format formatted date = total, with the total given to 2 decimal places. For example, with the simple 2-line input file above, the output would be 01 Jan 2010 = 30.00 02 Jan 2010 = 115.30 Notes: Your function should calculate and print the total for each line in the file. Days should be printed out in the same order as in the input file. Dates should be formatted DD Mon YYYY (see the examples above and below if you're not sure). The following dictionary will be useful to you: MONTHS = {1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec"} Hint: str.split will be very useful for the string processing you have to do. Read the documentation if you're not sure how to use it. Some of the data files used in testing can be downloaded here (click the link to download and save the file - then extract all the files to the same folder as your Python program). For example: Test Result = print_daily_totals('data90.txt') 10 Apr 2006 1399.46 11 Apr 2006 12 Apr 2006 13 Apr 2006 14 Apr 2006 15 Apr 2006 16 Apr 2006 20 Apr 2006 = 2822.36 = 2803.81 = 1622.71 = 3119.60 = 2256.14 = 3120.05 = 1488.00 print_daily_totals('data91.txt') 17 Sep 2001 25 Sep 2001 = 4071.00 = 1107.60 30 Oct 2002 = 4554.94

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Databases questions

Question

Graph one period of each function. y = 4 cos x

Answered: 1 week ago