From 009668bfa537958b39bc5227f1ee733f23148e50 Mon Sep 17 00:00:00 2001 From: thoritie Date: Tue, 30 Oct 2018 20:25:42 +0700 Subject: [PATCH] Clean old data c++ when i were student --- clean_data/merge_data.cpp | 84 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 clean_data/merge_data.cpp diff --git a/clean_data/merge_data.cpp b/clean_data/merge_data.cpp new file mode 100644 index 00000000..a30a1efb --- /dev/null +++ b/clean_data/merge_data.cpp @@ -0,0 +1,84 @@ +#include +#include +#include +#include + +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 -- > "< 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; + +}