Skip to content
Snippets Groups Projects
Commit f5c75b50 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Added index check to CSVReader.

parent 3643780c
No related branches found
No related tags found
No related merge requests found
......@@ -79,13 +79,18 @@ namespace lib4neuro {
//TODO check empty values in data
std::vector<double> input;
for(auto ind : *input_col_indices) {
/* Check, if the string is a number */
if(!std::regex_match( line.at(ind), std::regex( ( "((\\+|-)?[[:digit:]]+)(\\.(([[:digit:]]+)?))?" ) ))) {
THROW_RUNTIME_ERROR(std::string("Value \"") + line.at(ind) + "\" is not numerical and so it cannot be used in Data Set!");
}
try {
/* Check, if the string is a number */
if(!std::regex_match( line.at(ind), std::regex( ( "((\\+|-)?[[:digit:]]+)(\\.(([[:digit:]]+)?))?" ) ))) {
THROW_RUNTIME_ERROR(std::string("Value \"") + line.at(ind) + "\" is not numerical and so it cannot be used in Data Set!");
}
/* Add loaded number to the vector of inputs */
input.push_back(std::stod(line.at(ind)));
/* Add loaded number to the vector of inputs */
input.push_back(std::stod(line.at(ind)));
} catch(const std::out_of_range& e) {
THROW_OUT_OF_RANGE_ERROR("Non-existing index specified (" + std::to_string(ind) + ")!");
}
}
std::vector<double> output;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment