-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_data3.cpp
More file actions
66 lines (51 loc) · 1.39 KB
/
Copy pathread_data3.cpp
File metadata and controls
66 lines (51 loc) · 1.39 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
#include <iterator>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
// One function works for all data types. This would work
// even for user defined types if operator '>' is overloaded
template <typename T>
T myMax(T x, T y)
{
return (x > y)? x: y;
}
void generic_comparison()
{
cout << endl << "-------------------------------------------- " <<endl;
cout << "generic_comparison results : " <<endl;
cout << myMax<int>(3, 7) << endl; // Call myMax for int
cout << myMax<double>(3.0, 10.0) << endl; // call myMax for double
cout << myMax<char>('g', 'e') << endl; // call myMax for char
}
void read_csv(){
ifstream input_from_file("data.csv");
cout << endl << "-------------------------------------------- " <<endl;
string line;
vector < vector <string >> data ;
while (getline(input_from_file, line)) {
line += ",";
stringstream ss(line);
string word;
vector<string> words;
while (getline(ss, word, ',')){
words.push_back(word);
cout << word << " ";
}
cout << " --> number of cols : " << words.size() << endl;
for (auto c: words)
std::cout << c << ' ';
}
}
int main() {
read_csv();
generic_comparison() ;
return 0;
}