title: How to load values from csv file to a 2d vector<double>?
body: <p>I have a csv file with an 5 columns and 100 rows.
  My objective is to load the file into a vectorData</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt; 
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  using namespace std; 
  
  int main()
  {
  
  int count = 0;
  vector&lt;double&gt; data;
  string line;
  
  cout &lt;&lt; "Testing loading of file." &lt;&lt; endl;
  ifstream myfile ("iris.csv");
  if ( myfile.is_open() )
  {
       while ( ! myfile.eof() )
       {
             getline (myfile, line);
             data.push_back(line);
        // logs.at(count) = line;
             count++;
       }
       myfile.close();
  }else{
        cout &lt;&lt; "Unable to open file." &lt;&lt; endl;
  }
  cout &lt;&lt; "the log count is: " &lt;&lt; count &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>
  
  <p>I tried writing the above code to just enter 1 value into the vector but when I try to compile i get errors</p>
  
  <pre><code>lab6.cpp: In function ‘int main()’:
  lab6.cpp:22:35: error: no matching function for call to                        ‘std::vector&lt;double&gt;::push_back(std::__cxx11::string&amp;)’
              data.push_back(line);
                                 ^
  In file included from /usr/include/c++/6.3.1/vector:64:0,
                   from lab6.cpp:4:
  /usr/include/c++/6.3.1/bits/stl_vector.h:914:7: note: candidate: void             std::vector&lt;_Tp, _Alloc&gt;::push_back(const value_type&amp;) [with _Tp = double; _Alloc = std::allocator&lt;double&gt;; std::vector&lt;_Tp, _Alloc&gt;::value_type = double]
     push_back(const value_type&amp; __x)
     ^~~~~~~~~
  /usr/include/c++/6.3.1/bits/stl_vector.h:914:7: note:   no known     conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string&lt;char&gt;}’ to ‘const value_type&amp; {aka const double&amp;}’
  /usr/include/c++/6.3.1/bits/stl_vector.h:932:7: note: candidate: void std::vector&lt;_Tp, _Alloc&gt;::push_back(std::vector&lt;_Tp, _Alloc&gt;::value_type&amp;&amp;) [with _Tp = double; _Alloc = std::allocator&lt;double&gt;; std::vector&lt;_Tp, _Alloc&gt;::value_type = double]
     push_back(value_type&amp;&amp; __x)
     ^~~~~~~~~
  /usr/include/c++/6.3.1/bits/stl_vector.h:932:7: note:   no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string&lt;char&gt;}’ to ‘std::vector&lt;double&gt;::value_type&amp;&amp; {aka double&amp;&amp;}’
  </code></pre>
  
  <p>Can someone point me in the right direction Of how i can modify the code or start from scratch in order to load values into a 2d Vector?</p>
  
  <p>sample data from csv file.</p>
  
  <pre><code>-0.57815,0.83762,-1.0079,-1.0369,-1
  -0.88983,-0.20679,-1.0079,-1.0369,-1
  -1.2015,0.21097,-1.0769,-1.0369,-1
  -1.3573,0.0020888,-0.93891,-1.0369,-1
  -0.73399,1.0465,-1.0079,-1.0369,-1
  -0.11064,1.6731,-0.80094,-0.683,-1
  -1.3573,0.62874,-1.0079,-0.85994,-1
  </code></pre>