Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I have GIRMAY _ MULUGETA _ HW 4 _ csv . h , GIRMAY _ MULUGETA _ HW 4 _ csv . c , templates
I have GIRMAYMULUGETAHWcsvh GIRMAYMULUGETAHWcsvc templatesHWmain.c and CSVtest.c on template HWmaic.c I have this incomplete code help me complete it #include
#include
#include
#include
#include
#include
#include
#include
int main int argc, char argv
TO DO Look at arguments, initialize application
DO NOT CHANGE THIS BLOCK
Time stamp start
struct timespec startTime;
struct timespec endTime;
clockgettimeCLOCKREALTIME, &startTime;
TO DO start your thread processing
wait for the threads to finish
TO DO Display Data
DO NOT CHANGE THIS BLOCK
Clock output
clockgettimeCLOCKREALTIME, &endTime;
timet sec endTime.tvsec startTime.tvsec;
long nsec endTime.tvnsec startTime.tvnsec;
if endTimetvnsec startTime.tvnsec
sec;
nsec nsec L;
printfTotal Time was ldld seconds
sec nsec;
TO DO cleanup
and the rest instruction is as follow and complete each part a complete code please For part CSV Processing
A CSV or Comma Separated Values file is a text file where columnar field data is separated by commas. But to handle columns that have commas within them we have to enclose that field within quotation marks if the field has quotation marks in it then the entire field should be enclosed in quotation marks and the embedded quotation mark has to be doubled All records within a CSV file are separated by a newline. In simple terms, each line of the CSV file represents one record. But, a field may contain a newline. If a field does require a newline the entire field has to be enclosed in quotation marks. So more accurately each record of a CSV file is separated by a nonquoted newline.
For this part you will create a file using our naming conventions with csv as the option so HWcsvc You will also need a header file with the function prototypes.
You will need to implement functions:
csvopen: Opens a CSV file, reads the first line header and returns a nullterminated array of C string pointers a vector each representing a column name. This function should also prepare the file for reading subsequent lines. Return NULL on failure. The caller should NOT free the memory associated with the header.
char csvopen char filename;
csvnext: Reads the next line from the CSV file opened by csvopen, parses it according to CSV formatting rules including handling quoted fields, escaped quotes, and embedded newlines and returns a nullterminated array of strings vector each representing a cell value in the row.
char csvnext void;
csvheader: Returns the header read by csvopen as a nullterminated array of strings. This can be called at any time after csvopen to retrieve the header. The caller should NOT free the memory associated with the header.
char csvheader void;
csvclose: Closes the CSV file and frees any memory still associated with managing the file including the header. Return if an error otherwise return how many data lines had been read
int csvclose void;
To test your code run make test this will exercise the functions with the test program. Note that this is not comprehensive but does cover most cases.
This is what your output should look like when you run make test:
student@student:~CSCAssignmentCreationCSVThreads$ make test
BiermanRobertHWcsv
Header Column : Name Last, First
Header Column : Age
Header Column : Favorite Color
Header Column : Comments
Data for line
Field : Bierman, Robert
Field :
Field : Blue
Field : What can I say, this is a large comment
Data for line
Field : Smith, John
Field :
Field : Green
Field : I want to have a multiple
line comment
Data for line
Field : Clark, Dwight "The Catch"
Field :
Field : Red & Gold
Field : NFC Championship
CSV Tests Passed
student@student:~CSCAssignmentCreationCSVThreads$
For part Data Processing
For this part you will build a data structure that keeps tract of every event type specifically the field calltypefinaldesc, unless that field is blank then use the calltypeoriginaldesc field You will keep with each event type the total number of calls, the number of calls where the dispatch time is minutes or less, from to minutes, to minute, and over minutes, and the on scene times are minutes or less, from to minutes, to minute, and over
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