title: How to loop through vectors for specific strings
body: <p>I am struggling to declare a loop that takes a field of a vector, check whether it appears for the first time or jump to the next vector until this field contains a new string.</p>
  
  <p>My input file (.csvx) looks something like:</p>
  
  <pre><code>No.; ID; A; B; C;...;Z;
  1;1_380; Value; Value; Value;...; Value;
  2;1_380; Value; Value; Value;...; Value;
  3;1_380; Value; Value; Value;...; Value;
  ...
  41;2_380; Value; Value; Value;...; Value;
  42;2_380; Value; Value; Value;...; Value;
  ...
  400000; 6_392; Value; Value; Value;...; Value; 
  </code></pre>
  
  <p>Note:File is relatively large....</p>
  
  <p>I managed to parse my file into a <code>vector&lt;vector&lt;string&gt; &gt;</code> and split lines at semicolons to access any field. 
  Now I would like to access the first "ID", i.e. 1_380 and store parameters from same line, then go to the next ID 2_380 and store again those parameters and so on...</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  #include &lt;boost/algorithm/string.hpp&gt;
  
  using namespace std;
  
  /*
   * CSVX Reader defined to fetch data from 
   * CSVX file into vectors
   */
  class CSVXReader
  {
     string fileName, delimiter;
  public:
     CSVXReader(string filename, string delm = ";") :
     fileName(filename), delimiter(delm)
     {}
     vector&lt;vector&lt;string&gt; &gt; getData();           //Function to fetch data 
     };                                           //from CSVX file 
  
  /*
   * Parse through CSVX file line by line 
   * and return the data in vector of vector
   * of strings
   */
  vector&lt;vector&lt;string&gt; &gt; CSVXReader::getData()
  {
     ifstream file(fileName);
     vector&lt;vector&lt;string&gt; &gt; dataList;               //Vector of vector 
                                                     //contains all data
  
     string line = "";                              
     while (getline(file, line))                  //Iterate through each line 
                                                  //and split the content 
                                                  //using delimiter
     {
        vector&lt;string&gt; vec;                       //Vector contains a row from 
                                                  //input file 
        boost::algorithm::split(vec, line, boost::is_any_of(delimiter));
        dataList.push_back(vec);
     }
  file.close();
  return dataList;
  }
  
  
  int main(int argc, char** argv) 
  {
     CSVXReader reader("file.csvx");                     //Creating an object 
                                                         //of CSVXReader
     vector&lt;vector&lt;string&gt; &gt; dataList = reader.getData();//Get the data from 
                                                         //CSVX file
     for(vector&lt;string&gt; vec : datalist)                  //Loop to go through 
                                                         //each line of 
                                                         //dataList 
                                                         //(vec1,vec2;vec3...)
     if(vec[1] contains "_" &amp;&amp; "appears for the first time")
     {store parameters...};
     else{go to next line};
  return 0;
  }
  </code></pre>
  
  <p>As you can see, I have no clue how to declare my loop properly...
  To be clear, I want to check the second field of each vector "vec": is it new? -> Store data of same line, if not -> jump to next line, i.e. vector until a new ID appears.</p>
  
  <p>Looking forward for any advice!</p>