This repository has been archived on 2018-12-13. You can view files and clone it, but cannot push or open issues or pull requests.
arma-flow/src/reader.cpp

41 lines
908 B
C++

//
// arma-flow/reader.cpp
//
// @author CismonX
//
#include "reader.hpp"
#include <experimental/filesystem>
namespace flow
{
bool reader::from_csv_file(const std::string& path, bool remove_first_line)
{
std::ifstream ifstream;
ifstream.exceptions(std::ifstream::failbit);
namespace fs = std::experimental::filesystem;
try {
ifstream.open(
#ifdef _WIN32
path[1] == ':'
#else
path[0] == '/'
#endif // _WIN32
? path : fs::current_path().string() + '/' + path);
if (remove_first_line) {
ifstream.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
return do_read(ifstream);
}
catch (const std::exception&) {
return false;
}
}
const arma::mat& reader::get_mat() const
{
return mat_;
}
}