-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
224 lines (186 loc) · 7.76 KB
/
main.cpp
File metadata and controls
224 lines (186 loc) · 7.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <fstream>
#include <sstream>
#include <ctype.h>
using namespace std;
void RegisteredUsers();
string extractIntegerWords(string);
ofstream OutputFile;
vector<string> nameVec;
vector<string> typeVec;
vector<string> emailVec;
vector<string> SnameVec;
vector<string> SemailVec;
map<string,string> NameDate;
map<string,string> EmailDate;
map<string,string> NumberDate;
vector<string> NameNumber;
int main() {
OutputFile.open("Output.csv");
ifstream inFile("PayPal_List.csv");//change location based on location of file
ifstream SFile("Scholarship.csv");
std::string name,type,email,date,number;
getline(inFile,name);
string PName, GEmail;
getline(SFile, PName);
OutputFile<<"Name,Type,Email,Date,Number\n";
if (SFile.is_open()) {
while(getline(SFile, PName)){
stringstream SS(PName);
getline(SS , PName , ',');
getline(SS , PName , ',');
getline(SS , GEmail , ',');
getline(SS , GEmail , ',');
SnameVec.push_back(PName);
SemailVec.push_back(GEmail);
}
}
if (inFile.is_open()) {
while(getline(inFile, name)){
std::stringstream ss(name);
getline(ss , name , ',');
getline(ss , name , ',');
getline(ss , name , ',');
getline(ss , name , ','); //store name
getline(ss , type , ','); //store type
getline(ss , email , ',');
getline(ss , email , ',');
getline(ss , email , ',');
getline(ss , email , ',');
getline(ss , email , ',');
getline(ss , email , ','); //store email
if(type!="\"General Withdrawal\""&&type!="\"Donation Payment\""){
name.erase(name.begin());name.erase(name.size()-1);
transform(name.begin(), name.end(), name.begin(), ::tolower);
nameVec.push_back(name);
OutputFile<<name<<",";
typeVec.push_back(type);
OutputFile<<type<<",";
email.erase(email.begin());email.erase(email.size()-1);
std::transform(email.begin(), email.end(), email.begin(), ::tolower);
emailVec.push_back(email);
OutputFile<<email<<",";
getline(ss , date , ',');
getline(ss , date , ',');
getline(ss , date , ',');
getline(ss , date , '"');
getline(ss , date , ',');
getline(ss,date,',');
getline(ss,date,',');
stringstream pp(date);
getline(pp,date,'-');
getline(pp,date,'"');
NameDate.insert(pair<string,string>(name,date));
EmailDate.insert(pair<string,string>(email,date));
OutputFile<<date<<",";
getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');
getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');
getline(ss,number,'}');getline(ss,number,',');
// cout<<"Number : "<<number<<endl;
getline(ss,number,',');getline(ss,number,',');getline(ss,number,'"');getline(ss,number,'"');getline(ss,number,',');
getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');getline(ss,number,',');
getline(ss,number,',');getline(ss,number,',');
// getline(ss,number,',');
NameNumber.push_back(number);
NumberDate.insert(pair<string,string>(number,date));
OutputFile<<number<<"\n";
}
}
}
OutputFile.close();
SFile.close();
inFile.close();
RegisteredUsers();
return 0;
}
string extractIntegerWords(string str) {
string found="";
for(int x=0;x<str.size();x+=1){
if(isdigit(str[x])){
found+=str[x];
}
}
return found;
}
void RegisteredUsers() {
//C:\Users\shazmaan\Desktop\BlossomWork\Takeout\Mail
OutputFile.open("copy-mbox-output.csv");
ifstream inFile("mbox-output.csv");
string RowData, Parent, Email, Number, SecContact, SecNumber;
getline(inFile, RowData);
OutputFile << RowData + ",Payed,Date\n";
if (inFile.is_open()) {
while (getline(inFile, RowData)) {
std::stringstream ss(RowData);
std::stringstream ss2(RowData);
getline(ss2, Parent, ',');
getline(ss, RowData);
char c=ss2.peek();
if(c=='"'){
getline(ss2,Email,'"');
getline(ss2,Email,'"');
getline(ss2,Email,',');
ss2.get();
}else{
getline(ss2,Email,',');
}
// getline(ss2, Email, ',');
getline(ss2, Email, ',');
getline(ss2, Email, ',');
getline(ss2, Email, ',');
getline(ss2, Email, ',');
// cout<<"Email : "<<Email<<endl;
getline(ss2, Number, ',');
Number=extractIntegerWords(Number);
getline(ss2, SecContact,',');
getline(ss2, SecNumber,',');
SecNumber = extractIntegerWords(SecNumber);
// extractIntegerWords(Number);
// cout<<"Number : "<<extractIntegerWords(SecNumber)<<endl;
std::transform(Parent.begin(), Parent.end(), Parent.begin(), ::tolower);
std::transform(Email.begin(), Email.end(), Email.begin(), ::tolower);
std::transform(SecContact.begin(), SecContact.end(), SecContact.begin(), ::tolower);
bool Pcheck= (find(nameVec.begin(), nameVec.end(), Parent) != nameVec.end());
bool Echeck= (find(emailVec.begin(), emailVec.end(), Email) != emailVec.end());
bool Ncheck= (find(NameNumber.begin(),NameNumber.end(),"\""+Number+"\"")!=NameNumber.end());
bool Scheck= (find(NameNumber.begin(),NameNumber.end(),"\""+SecNumber+"\"")!=NameNumber.end());
bool Ccheck= (find(nameVec.begin(), nameVec.end(), SecContact) != nameVec.end());
bool SchPcheck= (find(SnameVec.begin(), SnameVec.end(), Parent) != SnameVec.end());
bool SchEcheck= (find(SemailVec.begin(), SemailVec.end(), Email) != SemailVec.end());
// cout<<"Parent : "<<Parent<<" Secondary Number : "<<SecNumber<<" Scheck : "<<Scheck<<endl;
// cout<<"-----------------------------"<<endl;
if (Pcheck || Echeck || Ncheck || Scheck || Ccheck || SchPcheck || SchEcheck) {
OutputFile << RowData + ",Yes,";
if(Pcheck){
// cout<<"Pcheck "<<endl;
OutputFile<<NameDate[Parent]+"\n";
}else if(SchPcheck){
// cout<<"IN"<<endl;
OutputFile<<"Scholarship Applicant\n";
}else if(Echeck){
// cout<<"Echeck "<<endl;
OutputFile<<EmailDate[Email]+"\n";
}else if(SchEcheck){
OutputFile<<"Scholarship Applicant\n";
}else if(Ncheck){
// cout<<"Ncheck "<<endl;
OutputFile<<NumberDate["\""+Number+"\""]+"\n";
}else if(Scheck){
// cout<<"Scheck "<<endl;
OutputFile<<NumberDate["\""+SecNumber+"\""]+"\n";
}else{
// cout<<"else "<<endl;
OutputFile<<NameDate[SecContact]+"\n";
}
} else {
OutputFile << RowData + ",No,\n";
}
}
OutputFile.close();
inFile.close();
}
}