fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <limits>
  5. #include <sstream>
  6. #include <string>
  7. #include <vector>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12. istringstream fileP{ "ConfigID\tLabel1\tLabel2\tLabel3\n1\t.3\t.3\t10.0\n2\t.2\t.2e-3\t0.1n3\t.4\t.2\t9.9" };
  13. string label;
  14.  
  15. getline(fileP, label, '\n');
  16.  
  17. istringstream gccNeedsThisOnASeperateLine{ label };
  18. const vector<string> Labels{ istream_iterator<string>{ gccNeedsThisOnASeperateLine }, istream_iterator<string>{} };
  19. vector<vector<double>> Parameters;
  20.  
  21. while(fileP.ignore(std::numeric_limits<std::streamsize>::max(), '\t')) {
  22. vector<double> input(Labels.size() - 1);
  23.  
  24. for(int i = 0; i < input.size() && fileP >> input[i]; ++i);
  25. Parameters.push_back(input);
  26. }
  27.  
  28. copy(next(cbegin(Labels)), cend(Labels), ostream_iterator<string>(cout, "\t"));
  29.  
  30. cout << endl;
  31.  
  32. for(const auto& input : Parameters) {
  33. for(const auto& i : input) {
  34. cout << i << '\t';
  35. }
  36. cout << endl;
  37. }
  38. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
Label1	Label2	Label3	
0.3	0.3	10	
0.2	0.0002	0.1	
0.4	0.2	9.9