-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCSVReader.cpp
More file actions
41 lines (32 loc) · 866 Bytes
/
Copy pathCSVReader.cpp
File metadata and controls
41 lines (32 loc) · 866 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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: CSVReader.cpp
* Author: wendell
*
* Created on 4 de Maio de 2018, 18:45
*/
#include "CSVReader.h"
/*
* Parses through csv file line by line and returns the data
* in vector of vector of strings.
*/
std::vector<std::vector<std::string> > CSVReader::getData()
{
std::ifstream file(fileName);
std::vector<std::vector<std::string> > dataList;
std::string line = "";
// Iterate through each line and split the content using delimeter
while (getline(file, line))
{
std::vector<std::string> vec;
boost::algorithm::split(vec, line, boost::is_any_of(delimeter));
dataList.push_back(vec);
}
// Close the File
file.close();
return dataList;
}