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 csv format, and
Write a C program that reads a csv file and find the monthly weather statistics. Requirements: The weather file is in 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 this format: csv filename.txt o For example, if the csv filename is weather.csv the result will be recorded in weather.csvtxt Example Interaction user input is underlined; your program must follow this format precisely without the underline: $ 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:
Write a C program that reads a csv file and find the monthly weather statistics.
Requirements: The weather file is in 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 this format: csv filename.txt
o For example, if the csv filename is weather.csv the result will be recorded in
weather.csvtxt
Example Interaction user input is underlined; your program must follow this format
precisely without the underline:
$ 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:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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