9 template<
typename COLNUM_STRUCTURE>
10 std::vector< std::list<double> > parse_columns(
18 const COLNUM_STRUCTURE &column_numbers,
25 int last_column=*max_element(column_numbers.begin(),
26 column_numbers.end());
28 std::vector< std::list<double> > result(column_numbers.size());
29 unsigned line_number=0;
30 for(std::getline(is, line); !is.eof(); std::getline(is, line)) {
33 std::ostringstream msg;
34 msg <<
"Failed to read line " << line_number
35 <<
" of the data section of an input stream in " 39 if(line[0]==
'#')
continue;
40 std::istringstream line_stream(line);
41 for(
int column_number=0; column_number<=last_column;
43 std::ostringstream msg;
44 msg <<
"Failed to parse column " << column_number
45 <<
" on line " << line_number <<
" of the data section of an" 46 " input stream in parse_columns.";
50 if(csv) std::getline(line_stream, word,
',');
51 else line_stream >> word;
52 typename COLNUM_STRUCTURE::const_iterator
53 colnum_iter=column_numbers.begin();
54 for(
size_t result_index=0; result_index<column_numbers.size();
55 ++result_index, ++colnum_iter)
56 if(*colnum_iter==column_number) {
59 else std::istringstream(word) >> value;
60 result[result_index].push_back(value);
const double NaN
Not a number.