title: C++ CSV Parsing with Commas Inside of Quotes
body: <p>I'm building a C++ CSV data parser. I'm trying to access the first and fifteenth columns of the file and read them into two arrays using <code>getline</code> commands. For example:</p>
  
  <pre><code>for(int j=0;j&lt;i;j++)
  {
      getline(posts2,postIDs[j],',');
      for(int k=0;k&lt;14;k++)
      {
          getline(posts2,tossout,',');
      }
      getline(posts2,answerIDs[j],',');
      getline(posts2,tossout,'\r');
  </code></pre>
  
  <p>But, in-between the first and fifteenth columns is a column that is in quotes and contains various commas and loose quote marks. For example:</p>
  
  <blockquote>
    <p>...,"abc, defghijk. "Lmnopqrs, "tuv,"" wxyz.",... &lt;</p>
  </blockquote>
  
  <p>What would the best way to avoid this column be? I can't getline over it because there are quotes and commas inside of it. After running into a quote, should I read the quoted junk character-by-character until I find <strong>",</strong>  in sequence?</p>
  
  <p>Also, I've seen other solutions, but all of them have been exclusive to Windows/Visual Studio. I'm running Mac OSX ver. 10.8.3 with Xcode 3.2.3.</p>
  
  <p>Thanks in advance!
  Drew</p>