forked from srora/kdtree
-
Notifications
You must be signed in to change notification settings - Fork 1
/
read.cpp
58 lines (48 loc) · 910 Bytes
/
read.cpp
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
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<vector<double>> points;
points readData()
{
ifstream dataFile("dataset.txt");
string line;
int dimension = 0;
int numberOfPoints = 0;
points all_points;
if (dataFile.is_open())
{
int i = 0;
while (! dataFile.eof() )
{
stringstream ss;
getline (dataFile,line);
ss.str(line);
if(line == ""){
continue;
}
if (i==0){
ss>>dimension;
ss>>numberOfPoints;
i++;
continue;
}
vector<double> point;
for(int j=0;j<dimension;j++){
double x;
ss>>x;
point.push_back(x);
}
all_points.push_back(point);
i++;
}
}
return all_points;
}
int main(){
points p = readData();
cout<<p.size()<<endl;
return 0;
}