Commit bc290134 authored by Markus Mirz's avatar Markus Mirz
Browse files

csvreader: use cps types


Signed-off-by: Markus Mirz's avatarMarkus Mirz <mmirz@eonerc.rwth-aachen.de>
parent 9654eb92
...@@ -65,7 +65,7 @@ namespace CPS { ...@@ -65,7 +65,7 @@ namespace CPS {
/// Skip first row if it has no digits at beginning /// Skip first row if it has no digits at beginning
void doSkipFirstRow(Bool value = true) { mSkipFirstRow = value; } void doSkipFirstRow(Bool value = true) { mSkipFirstRow = value; }
/// ///
MatrixRow csv2Eigen(const std::string& path); MatrixRow csv2Eigen(const String& path);
std::vector<PQData> readLoadProfileDP(std::experimental::filesystem::path file, std::vector<PQData> readLoadProfileDP(std::experimental::filesystem::path file,
Real start_time = -1, Real time_step = 1, Real end_time = -1, Real scale_factor= 1, Real start_time = -1, Real time_step = 1, Real end_time = -1, Real scale_factor= 1,
......
...@@ -13,21 +13,21 @@ namespace fs = std::experimental::filesystem; ...@@ -13,21 +13,21 @@ namespace fs = std::experimental::filesystem;
using namespace CPS; using namespace CPS;
MatrixRow CSVReader::csv2Eigen(const std::string& path) { MatrixRow CSVReader::csv2Eigen(const String& path) {
std::ifstream inputFile; std::ifstream inputFile;
inputFile.open(path); inputFile.open(path);
std::string line; String line;
std::vector<double> values; std::vector<double> values;
uint rows = 0; UInt rows = 0;
while (std::getline(inputFile, line)) { while (std::getline(inputFile, line)) {
std::stringstream lineStream(line); std::stringstream lineStream(line);
std::string cell; String cell;
while (std::getline(lineStream, cell, ',')) { while (std::getline(lineStream, cell, ',')) {
values.push_back(std::stod(cell)); values.push_back(std::stod(cell));
} }
++rows; ++rows;
} }
uint columns = values.size()/rows; UInt columns = values.size()/rows;
return Eigen::Map<const MatrixRow>(values.data(), rows, columns); return Eigen::Map<const MatrixRow>(values.data(), rows, columns);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment