title: sqldf, csv, and fields containing commas
body: <p>Took me a while to figure this out. So, I am <a href="https://blog.stackoverflow.com/2011/07/its-ok-to-ask-and-answer-your-own-questions/">answering my own question</a>.</p>
  <p>You have some .csv, you want to load it <a href="https://stackoverflow.com/questions/1727772/quickly-reading-very-large-tables-as-dataframes-in-r/1820610#1820610">fast</a>, you want to use the <code>sqldf</code> package. Your usual code is irritated by a few annoying fields. Example:</p>
  <pre><code>1001,     Amy,9:43:00, 99.2
  1002,&quot;Ben,Jr&quot;,9:43:00, 99.2
  1003,&quot;Ben,Sr&quot;,9:44:00, 99.3
  </code></pre>
  <p>This code only works on *nix systems.</p>
  <pre><code>library(sqldf)
  system(&quot;touch temp.csv&quot;)
  system(&quot;echo '1001, Amy,9:43:00, 99.2\n1002,\&quot;Ben,Jr\&quot;,9:43:00, 99.2\n1003,\&quot;Ben,Sr\&quot;,9:44:00, 99.3' &gt; temp.csv&quot;)
  </code></pre>
  <p>If try to read with</p>
  <pre><code>x &lt;- read.csv.sql(&quot;temp.csv&quot;, header=FALSE)
  </code></pre>
  <p>R complains</p>
  <pre><code>Error in try({ : 
    RS-DBI driver: (RS_sqlite_import: ./temp.csv line 2 expected 4 columns of data but found 5)
    
  </code></pre>
  <p>The <code>sqldf</code>-<a href="http://code.google.com/p/sqldf/#13._How_does_one_deal_with_quoted_fields_in_read.csv.sql_?" rel="nofollow noreferrer">FAQ.13</a> solution doesn't work either:</p>
  <pre><code>x &lt;- read.csv.sql(&quot;temp.csv&quot;, filter = &quot;tr -d '\&quot;' &quot;, header=FALSE)
  </code></pre>
  <p>Again, R complains</p>
  <pre><code>Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
    line 1 did not have 5 elements
  </code></pre>
  <p>In fact, the filter only removes double quotes.</p>
  <p>So, how to proceed?</p>