Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have GIRMAY _ MULUGETA _ HW 4 _ csv . h , GIRMAY _ MULUGETA _ HW 4 _ csv . c , templates

I have GIRMAY_MULUGETA_HW4_csv.h , GIRMAY_MULUGETA_HW4_csv.c , templates_HW4_main.c and CSVtest.c on template _HW4.maic.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;
clock_gettime(CLOCK_REALTIME, &startTime);
//**************************************************************
//*** TO DO *** start your thread processing
// wait for the threads to finish
//***TO DO *** Display Data
//**************************************************************
// DO NOT CHANGE THIS BLOCK
//Clock output
clock_gettime(CLOCK_REALTIME, &endTime);
time_t sec = endTime.tv_sec - startTime.tv_sec;
long n_sec = endTime.tv_nsec - startTime.tv_nsec;
if (endTime.tv_nsec < startTime.tv_nsec)
{
--sec;
n_sec = n_sec +1000000000L;
}
printf("Total Time was %ld.%09ld seconds
", sec, n_sec);
//**************************************************************
//***TO DO *** cleanup
}
and the rest instruction is as follow and complete each part a complete code please For part 1- 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 non-quoted newline.
For this part you will create a file using our naming conventions with csv as the option - so __HW4_csv.c. You will also need a header file with the 4 function prototypes.
You will need to implement 4 functions:
csvopen: Opens a CSV file, reads the first line (header), and returns a null-terminated 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 null-terminated array of strings (vector), each representing a cell value in the row.
char ** csvnext (void);
csvheader: Returns the header read by csvopen as a null-terminated 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 -1 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 4 functions with the test program. Note that this is not 100% comprehensive but does cover most cases.
This is what your output should look like when you run make test:
student@student:~/CSC415/AssignmentCreation/CSVThreads$ make test
./Bierman_Robert_HW4_csv
Header Column 00: Name - Last, First
Header Column 01: Age
Header Column 02: Favorite Color
Header Column 03: Comments
Data for line 1
Field 00: Bierman, Robert
Field 01: 943
Field 02: Blue
Field 03: What can I say, this is a large comment
Data for line 2
Field 00: Smith, John
Field 01: 28
Field 02: Green
Field 03: I want to have a multiple
line comment
Data for line 3
Field 00: Clark, Dwight "The Catch"
Field 01: 61
Field 02: Red & Gold
Field 03: 1981 NFC Championship
CSV Tests Passed
student@student:~/CSC415/AssignmentCreation/CSVThreads$
For part 2- Data Processing
For this part you will build a data structure that keeps tract of every event type (specifically the field call_type_final_desc, unless that field is blank then use the call_type_original_desc field). You will keep with each event type the total number of calls, the number of calls where the dispatch time is 2 minutes or less, from 3 to 5 minutes, 6 to 10 minute, and over 10 minutes, and the on scene times are 2 minutes or less, from 3 to 5 minutes, 6 to 10 minute, and over

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

More Books

Students also viewed these Databases questions

Question

3. Contrast relational contexts in organizations

Answered: 1 week ago

Question

2. Describe ways in which organizational culture is communicated

Answered: 1 week ago

Question

1. Describe and compare approaches to managing an organization

Answered: 1 week ago