-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathread_csv.cpp
More file actions
49 lines (40 loc) · 949 Bytes
/
read_csv.cpp
File metadata and controls
49 lines (40 loc) · 949 Bytes
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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
int main()
{
string fname = "/home/research-student/omnet-fanet/data-processing-scripts/Stationary_Test_Dataset_NP10000_BPSK_6-5Mbps_downlink_RESULTS_nn_V2-2.csv";
vector<vector<string>> content;
vector<string> row;
string line, word;
fstream file (fname, ios::in);
if(file.is_open())
{
getline(file, line);
while(getline(file, line))
{
row.clear();
stringstream str(line);
while(getline(str, word, ','))
row.push_back(word);
content.push_back(row);
}
}
else
cout<<"Could not open the file\n";
cout << setprecision(9) << fixed;
for(int i=0;i<content.size();i++)
{
cout << std::stoi(content[i][0]) + std::stod(content[i][1]) << "\n";
// for(int j=0;j<content[i].size();j++)
// {
// cout<<content[i][j]<<" ";
// }
// cout<<"\n";
}
return 0;
}