title: Parsing a huge complicated CSV file using C++
body: <p>I have a large CSV file which looks like this:</p>
  
  <p>23456, The End is Near, A silly description that makes no sense, <a href="http://www.example.com" rel="nofollow">http://www.example.com</a>, 45332, 5th July 1998 Sunday, 45.332</p>
  
  <p>That's just one line of the CSV file. There are around 500k of these. </p>
  
  <p>I want to parse this file using C++. The code I started out with is: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  int main()
  {
      // open the input csv file containing training data
      ifstream inputFile("my.csv");
  
      string line;
  
      while (getline(inputFile, line, ','))
      {
          istringstream ss(line);
  
          // declaring appropriate variables present in csv file
          long unsigned id;
          string url, title, description, datetaken;
          float val1, val2;
  
          ss &gt;&gt; id &gt;&gt; url &gt;&gt; title &gt;&gt; datetaken &gt;&gt; description &gt;&gt; val1 &gt;&gt; val2;
  
          cout &lt;&lt; url &lt;&lt; endl;
      }
      inputFile.close();
  }
  </code></pre>
  
  <p>The problem is that it's not printing out the correct values. </p>
  
  <p>I suspect that it's not able to handle white spaces within a field. So what do you suggest I should do?</p>
  
  <p>Thanks</p>