diff --git a/src/CSVReader/CSVReader.cpp b/src/CSVReader/CSVReader.cpp index 71352024fdd1768b59f5b7a81ce2b0074ff647e1..373dcd1ecff985e79551d762b62f8f939de1619b 100644 --- a/src/CSVReader/CSVReader.cpp +++ b/src/CSVReader/CSVReader.cpp @@ -80,10 +80,15 @@ namespace lib4neuro { std::vector<std::pair<std::vector<double>, std::vector<double>>> data_set_contents; - for(auto line : *this->data) { + if(this->data->empty()) { + THROW_LOGIC_ERROR("DataSet can not be created as there were no data read beforehand! Did you forget to call " + "the method 'read()'?"); + } + + for (auto line : *this->data) { //TODO check empty values in data std::vector<double> input; - for(auto ind : *input_col_indices) { + for (auto ind : *input_col_indices) { std::string s; try { @@ -102,16 +107,17 @@ namespace lib4neuro { /* Add loaded number to the vector of inputs */ input.push_back(tmp); - } catch(const std::out_of_range& e) { + } catch (const std::out_of_range& e) { THROW_OUT_OF_RANGE_ERROR("Non-existing index specified (" + std::to_string(ind) + ")!"); } catch (const boost::bad_lexical_cast& e) { - THROW_RUNTIME_ERROR("Value \"" + s + "\" is not numerical and so it cannot be used in Data Set!"); + THROW_RUNTIME_ERROR( + "Value \"" + s + "\" is not numerical and so it cannot be used in Data Set!"); } } std::vector<double> output; - for(auto ind : *output_col_indices) { + for (auto ind : *output_col_indices) { output.emplace_back(std::stod(line.at(ind))); }