title: Convert CSV column of strings to integers with CSV lib in Ruby 1.9
body: <p>So I have a CSV with two columns that contain dollar amounts in string format. <code>head -n 5 file.csv</code> reveals the following:</p>
  
  <pre><code>Title,Distributor Long Name,Wk,Estimated Weekend Gross,Cume,Locs Reported,Avg/Loc,Booking Title #
  "=""Zero Dark Thirty""","=""Sony""",4,"24,000,000","29,480,807",2937,"8,172","=""66273"""
  "=""Haunted House, A""","=""Open Road""",1,"18,817,000","18,817,000",2160,"8,712","=""71209"""
  "=""Gangster Squad""","=""Warner Bros.""",1,"16,710,000","16,710,000",3103,"5,385","=""66556"""
  "=""Django Unchained""","=""The Weinstein Company""",3,"11,065,000","125,399,122",3012,"3,674","=""66122"""
  </code></pre>
  
  <p>This goes on for about 40 rows. You'll notice two of the columns — the "Estimated Weekend Gross" and "Cume" ones — have their values as <strong>strings</strong>.</p>
  
  <p>So my question is, is there a way to iterate over only these two columns, convert the string values to integers doing something like <code>row.to_s.gsub(',','').to_i</code> and then overwrite those values to their respective rows in the <strong>same</strong> CSV?</p>
  
  <p>I tried doing something like this, but I'm not getting a properly formatted CSV..</p>
  
  <pre><code>File.open('modified.csv', 'w') do |csv|
    CSV.foreach('original.csv') do |row|
      csv &lt;&lt; row[0].to_s.gsub('=','').gsub(', The','')
      csv &lt;&lt; row[3].to_s.gsub(',','').to_i
      csv &lt;&lt; row[4].to_s.gsub(',','').to_i
    end
  end
  </code></pre>
  
  <p>I've also played around with <code>:headers =&gt; :integer</code> when doing the block, but it won't let me convert the values from strings to integers. So, what am I missing? Should I store these values and then write a new CSV or is there a simpler way?</p>