Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean old data c++ when i were student #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions clean_data/merge_data.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include <iostream>
#include <fstream>
#include <string>
#include <map>

using namespace std;
void find(string word) {
string line;
int count = 0;

ifstream myfile ("/Users/swe_mini/Desktop/a.txt");


if (myfile.is_open())

{
while(getline(myfile, line)){

if(line.find(word) != string::npos){
//cout << word << endl;
count ++;


}

}

cout <<"its -- > "<<count << endl;




myfile.close();

}

else cout << "Unable to open file";
}

int main () {

string line;
//string word = "elder High High School Wife relative Female gain relax United-States >50K";
int count = 0;


typedef map<string, int> line_record;
line_record lines;
int line_number = 1;


ifstream mergeFile ("/Users/swe_mini/Desktop/merge.txt");
ifstream myfile ("/Users/swe_mini/Desktop/a.txt");

if (mergeFile.is_open())
{
while ( getline (mergeFile,line) )
{
line_record::iterator existing = lines.find(line);
if(existing != lines.end())
{
existing->second = (-1);

} else
{
lines.insert(make_pair(line,line_number));
++line_number;

find(line);
count++;
}



}
mergeFile.close();
}

else cout << "Unable to open file";


return 0;

}