title: Reading in text file with unmatched quotes
body: <p>I have a large (>1GB) CSV file I'm trying to read into a data frame in R.</p>
  
  <p>The non-numeric fields are enclosed in double-quotes so that internal commas are not interpreted as delimiters. That's well and good. However, there are also sometimes unmatched double-quotes in an entry, like <code>"2" Nails"</code>.</p>
  
  <p>What is the best way to work around this? My current plan is to use a text processor like awk to relabel the quoting character from the double-quote <code>"</code> to a non-conflicting character like pipe <code>|</code>. My heuristic for finding quoting characters would be double-quotes next to a comma:</p>
  
  <pre><code>gawk '{gsub(/(^\")|(\"$)/,"|");gsub(/,\"/,",|");gsub(/\",/,"|,");print;}' myfile.txt &gt; newfile.txt 
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/17763294/all-lines-not-being-read-while-executing-read-csv-in-r/17763959">This question</a> is related, but the solution (argument in <code>read.csv</code> of <code>quote=""</code>) is not viable for me because my file has non-delimiting commas enclosed in the quotation marks.</p>