Please help with my project

Please help

C++ only

It is suggested to use functions to comply with program modularization. Part of the task is read/write external files; two input files were provided (currentData.csv & newData.csv) with approximately 100 records. Your task is to create an application that will compare the two input files and write to three output files (toAdd.csv, toDel.csv & final.csv). The output files should contain only records according to the following criteria:

a. If a record in newData.cvs is not in currentData.cvs then new record should be written to toAdd.csv file

b. If a record in currentData.csv doesn’t exist in newData.csv then record should be written to toDel.csv file

c. Merge necessary files to obtain an updated version of new currentData.csv in such way that records in toAdd.csv and toDel.csv files are removed or added respectively to create a new version of currentData.csv file that you could name the file final.csv.

The suggested key field to be used for finding and comparing each file record is the ID field.

newData.csv: https://docs.google.com/document/d/1nqdMz0D164gGVCBm_ega-QzaQwaUww4XxldcTwgkv8s/edit?usp=sharing

currentData.csv: https://docs.google.com/document/d/1Fx-OIqRySvUxjSqfS_Wr2_a4OSYhlfCdMv_s-_yUY58/edit?usp=sharing
this is what i have so far:
#include <iostream>
#include <fstream>

using namespace std;

int main(){


ifstream inFile1("newData");
ifstream inFile2("CurrentData");
ofstream outFile12("outdata12.csv");

if(!inFile1.is_open() || !inFile2.is_open())
{
cout << "ERROR READ: File Open" << '\n';
}
if(!outFile12.is_open())
{
cout << "ERROR WRITE: File Write" << '\n';
}

string firstname1;
string lastname1;
string ID1;
string email1;

string firstname2;
string lastname2;
string ID2;
string email2;
int i=0;
while(!inFile1.eof() && !inFile2.eof())
{ getline(inFile1,firstname1,',');
getline(inFile1,lastname1,',');
getline(inFile1,ID1,',');
getline(inFile1,email1,'\n');

getline(inFile2,firstname2,',');
getline(inFile2,lastname2,',');
getline(inFile2,ID2,',');
getline(inFile2,email2,'\n');

if( inFile1.eof() )
{ cout<<"EOF was found in file data1";
break;
} //Jumps to read EOF
if( inFile2.eof() )
{ cout<<"EOF was found in file data2";
break;
} //Jumps to read EOF
//if( inFile2.eof() ) break;
cout<< ".";



outFile12 <<"Record: " <<i++<<'\n';
outFile12 << "Name: "<<firstname1<< " "<<lastname1 << '\n';
outFile12 << "ID: "<<ID1 << '\n';
outFile12 << "Email: "<<email1 << '\n';
outFile12 << "-------------------" <<'\n';

outFile12 << "Name: "<<firstname2<< " "<<lastname2 << '\n';
outFile12 << "ID: "<<ID2 << '\n';
outFile12 << "Email: "<<email2 << '\n';
outFile12 << "-------------------" <<'\n';


}

inFile1.close();
inFile2.close();
outFile12.close();
}
Last edited on
Please note that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
i've updated with what i have done so far, any help would be appriciated
Please help

Your lack of specificity isn't going to get you anywhere. What do you need help with? What's not working the way you expect it to? What are you having trouble implementing? Help others help you by supplying appropriate context and information unless you're just trying to get someone to do it for you, in which case you should continue being lazy and hope you get lucky.

Maybe google "How to ask a programming question"
Registered users can post here. Sign in or register to post.