title: Ruby: CSV parser tripping over double quotation in my data
body: <p>I 'm working on a daily scheduled rake task that will download a CSV that is automatically sent to Dropbox every day, parse it and save to the database. I don't have control over the way the data is entered into the program that generates the CSV reports for this, so I can't avoid there being double quotes used in some of the data. However, I am wondering if there is a way I can strip or replace them with single quotes within the rake task or somehow inform the parser so it doesn't throw this error.</p>
  
  <p>Rake task code:</p>
  
  <pre><code>require 'net/http'
  require 'csv'
  require 'open-uri'
  
  namespace :fp_import do
      desc "download abc_relations from dropbox, save as csv, create or update record in db"
      task :fp =&gt; :environment do
          data = URI.parse("&lt;&lt;file's dropbox link&gt;&gt;").read
  
         File.open(Rails.root.join('lib/assets', 'fp_relation.csv'), 'w') do |file|
           file.write(data)
         end
  
         file= Rails.root.join('lib/assets', 'fp_relation.csv')
  
          CSV.foreach(file) do |row|
              div, fg_style, fg_color, factory, part_style, part_color, comp_code, vendor, design_no, comp_type = row
              fg_sku = fg_style + "-" + fg_color
              part_sku = part_style + "-" + part_color
  
              relation = FgPart.where('part_sku LIKE ? AND fg_sku LIKE?', "%#{part_sku}%", "%#{fg_sku}%").exists?
              if relation == false
  
                  FgPart.create(fg_style: fg_style, fg_color: fg_color, fg_sku: fg_sku, factory: factory, part_style: part_style, part_color: part_color, part_sku: part_sku, comp_code: comp_code, comp_type: comp_type, design_no: design_no)
              end
          end
      end
  end
  </code></pre>
  
  <p>There are about 35,000 rows in this CSV. Below is a sample. You can see the double quotes in the 4th row of the sample.<br></p>
  
  <p>Sample data:<br></p>
  
  <pre><code>"01","502210","018","ZH","5931","001","M","","UPHOLSTERED GLIDER A","RM"
  "01","502310","053","ZH","25332","NO","O","","UPHOLSTERED GLIDER","BAG"
  "01","502310","065","ZH","25332","NO","O","","UPHOLSTERED GLIDER","BAG"
  "01","502312","424","ZH","25332","NO","O","","UPHOLSTERED GLIDER"AUS"","BAG"
  "01","503210","277","ZH","25332","NO","O","","UPHOLSTERED GLIDER","BAG"
  "01","503310","076","ZH","25332","NO","O","","UPHOLSTERED GLIDER","BAG"
  "01","506210","018","ZH","25332","NO","O","","UPHOLSTERED GLIDER","BAG"
  "01","506210","467","ZH","25332","NO","O","","UPHOLSTERED GLIDER","BAG"
  "01","507610","932","AZ","25332","NO","O","","GLIDER","BAG"
  "01","507610","932","AZ","5936","001","M","","GLIDER","RM"
  </code></pre>