Question: I have a C++ assignment that involves IO. I have a database file with comma separated values. The values are in the format (index, department,
I have a C++ assignment that involves IO. I have a database file with comma separated values. The values are in the format (index, department, item code, quantity, cost). There are duplicates in this database file. I need to read in the database, remove the duplicates, and write a new comma separated database file without the duplicates. The index field in the new file must be sequential and start at one. My program will be run against other files of the same format so it shouldn't be designed for just one file..
Program tasks:
Prompt the user for the database file name. This file name is the path and the file name. For example "/home/Resource/database.csv". Do not assume the file is in a particular directory. Use a single prompt.
Open the database
Read in the records using a custom class to hold a record
Remove the duplicates. Note: A duplicate is identified by all four fields being the same
Write the scrubbed database as a new CSV file starting with 'new_' and the input database file name.
Write the new file to the same directory that the database file was read from. For example "/home/student/lab8/Resource/new_database.csv"
The index field in the new file must be sequential and start at one.
It is recommended to:
-Create a class to hold a single data record
-Override the == operator to ease comparison and override the << to output the comma separated values
-Use the class constructor to receive a line from the database then parse the values or override the >> input operators
-Modify the string stream getline() delimiter to a comma.
-Use a vector to contain the data records
-keep an eye out for potential errors from bad data records
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
