title: Ruby CSV read multiline fields
body: <p>I exported tables and queries from SQL, where some of the fields are multi-line.</p>
  
  <p>The Ruby (1.9+) way to read CSV appears to be:</p>
  
  <pre><code>require 'csv'
  
  CSV.foreach("exported_mysql_table.csv", {:headers=&gt;true}) do |row|
      puts row
  end
  </code></pre>
  
  <p>Which works great if my data is like this:</p>
  
  <pre><code>"id","name","email","potato"
  1,"Bob","bob@bob.bob","omnomnom"
  2,"Charlie","char@char.com","andcheese"
  4,"Doug","diggyd@diglet.com","usemeltattack"
  </code></pre>
  
  <p>(The first line is the header/attributes)</p>
  
  <p>But if I have:</p>
  
  <pre><code>"id","name","address","email","potato"
  1,"Bob","--- 
  - 101 Cottage row
  - Lovely Village
  - \"\"
  ","bob@bob.bob","omnomnom"
  2,"Charlie","--- 
  - 102 Flame Street
  - \"\"
  - \"\"
  ","char@char.com","andcheese"
  4,"Doug","--- 
  - 103 Dark Cave
  - Next to some geo dude
  - So many bats
  ","diggyd@diglet.com","usemeltattack"
  </code></pre>
  
  <p>Then I get the error:</p>
  
  <pre><code>.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/csv.rb:1894:in `block (2 levels) in shift': Missing or stray quote in line 2 (CSV::MalformedCSVError)
  </code></pre>
  
  <p>This seems to be because the end of the line doesn't have a close quote, as it spans several lines.</p>
  
  <p>(I tried 'FasterCSV', that gem became 'csv' since ruby 1.9)</p>