Question: using C language please help me do For part 1 - CSV Processing A CSV ( or Comma Separated Values ) file is a text

using C language please help me do 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); 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 10 minutes. You will also selectively keep track of those times for either 3 neighborhoods or police districts. Specifically 3 values from the analysis_neighborhood field or the police_district field depending on the command line parameters. To calculate dispatch time parse and subtract the received_datetime from the dispatch_datetime. To calculate the on scene time parse and subtract the enroute_datetime from the onscene_datetime.
The output should be well formatted and columnar with clear headings. The event type should print our in alphabetical order. This is a short example of what the output can look like:
Screenshot of a sample output.
You my use any data structure you like to hold the data as it is being processed, but it must be global (i.e. each thread will be adding directly to it and mot merging at the end) and you have to write the data structure code yourself, not using libraries. (Note: using string libraries for copying and comparing are okay).
For part 3- Threading The catch, it is to do all this using threads. Each thread will request the next record of the file and process it, returning its results tallied to shared memory and then the main will print the results as specified above. Remember that this assignment will be using the pthread functions. But we want to determine how long the program takes using different number of threads (separate runs). To do so
#include in your code and in main, include the code below in your main. This will display how much time your program takes. Your submission should include a run with 1 thread, 2 threads, 4 threads, and 8 threads. How do the times compare?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!