Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C program that reads a csv file and find the monthly weather statistics. Requirements: - The weather file is in comma - delimited
Write a C program that reads a csv file and find the monthly weather statistics.
Requirements: The weather file is in commadelimited csv format, and the first line is the header
line. The weather file contains three columns: month, day and temperature. You find the average for each month. Your program should check if the month is from to and the day is from to
If there are multiple rows for a specific month and a day, only use the first row for
calculations.
o Hint: you can maintain a D array month x day to keep track of which days
have already been used for calculations. The average temperature is calculated by total temperaturenumber of days
calculated
o For example, if there are days for January, the temperatures will be
summed and then divided by to find the average temperature. The statistics should be written in the output file named: csv filenametxt
without the parenthesis.
o For example, if the csv filename is weathercsv the result will be recorded in
weathercsvtxt You can print out the content of the output file using the cat command. The
below is the usage of the command.
o cat Follow the example interaction for the output format.
Example Interaction all interactions are commandline interactions:
$ gcc Wall assignmentc
$ aout jan.csv
$
$
$ cat jan.csvtxt
Jan
Measured days:
Average temperature:
Total
Measured months:
Measured days:
Average temperature:
$ aout random.csv
$ cat random.csvtxt
Feb
Measured days:
Average temperature:
Jul
Measured days:
Average temperature:
Total
Measured months:
Measured days:
Average temperature:
$
$
$ aout randomcsv
$
$
$ cat randomcsvtxt
Aug
Measured days:
Average temperature:
Dec
Measured days:
Average temperature:
Total
Measured months:
Measured days:
Average temperature:
$
$
$ aout weather.csv
$
$
$ cat weather.csvtxt
Jan
Measured days:
Average temperature:
Feb
Measured days:
Average temperature:
Mar
Measured days:
Average temperature:
Apr
Measured days:
Average temperature:
May
Measured days:
Average temperature:
Jun
Measured days:
Average temperature:
Jul
Measured days:
Average temperature:
Aug
Measured days:
Average temperature:
Sep
Measured days:
Average temperature:
Oct
Measured days:
Average temperature:
Nov
Measured days:
Average temperature:
Dec
Measured days:
Average temperature:
Total
Measured months:
Measured days:
Average temperature:
Please make sure the average temperature is correct.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started