Question: **C PROGRAMMING** I have a program that runs mergesort on csv files based on a certain column that is decided by the user. How would

**C PROGRAMMING** I have a program that runs mergesort on csv files based on a certain column that is decided by the user. How would we implement the following?

a. Parameters Your code will read in a set of parameters via the command line. Records will be stored in .csv files in the provided directory. As mentioned above, directory structures may have multiple levels and you must find all .csv files. Your code should ignore non .csv files and .csv files that do not have the correct format of the movie_metadata csv (e.g. csv files that have other random data in them). Remember, the first record (line) is the column headings and should not be sorted as data. Your code must take in a command-line parameter to determine which value type (column) to sort on. If that parameter is not present (?-> throw an error, or default behavior). The first argument to your program will be '-c' to indicate sorting by column and the second will be the column name: ./sorter -c food Be sure to check the arguments are there and that they correspond to a listed value type (column heading) in the CSV. For this phase you'll extend your flags from one to three. The second parameter to your program will be -d indicating the directory the program should search for .csv files. This parameter is optional. The default behavior will search the current directory. ./sorter -c food -d thisdir/thatdir The third parameter to your program will be -o indicating the output directory for the sorted versions of the input file. This parameter is optional. The default behavior will be to output in the same directory as the source file. ./sorter -c movie_title -d thisdir -o thatdir b. Operation Your code will be reading in and traversing the entire directory. In order to run your code to test it, you will need to open each CSV and read it for processing: ./sorter -c movie_title -d thisdir -o thatdir Your code's output will be a series of new CSV files outputted to the file whose name is the name of the CSV file sorted, with "-sorted-" postpended to the name. e.g: 'movie_metadata.csv' sorted on the field 'movie_title' will result in a file named "movie_metadata-sorted-movie_title.csv". On each new file in a directory you encounter, you should fork() a child process to do the actual sorting. On each new directory you encounter, you should fork() a child process to process the directory. To STDOUT, output the following metadata in the shown order: Initial PID: XXXXX PIDS of all child processes: AAA,BBB,CCC,DDD,EEE,FFF, etc Total number of processes: ZZZZZ You may assume the total number of files and directories will not exceed 255. c. Structure Your code should use Mergesort to do the actual sorting of records. It is a powerful algorithm with an excellent average case. Results: Submit your "sorter.c", "sorter.h" and "mergesort.c" as well as any other source files your header file references. Document your design, assumptions, difficulties you had and testing procedure. Include any test CSV files you used in your documentation. Be sure to also include a short description of how to use your code. Look at the man pages for suggestions on format and content. Do not neglect your header file. Be sure to describe the contents of it and why you needed them.

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!