title: Trouble writing to a workbook using ruby spreadsheet gem from CSV file
body: <p>I am currently new to Ruby and am having a hard time writing to an excel file.</p>
  
  <p>I want to parse through a CSV file, extract data where the 'food' column in the csv file = butter and put the rows where 'food' column = butter into a new excel workbook. I can write the data that contains butter in the 'food' column just fine into a CSV file but am having trouble writing it to a workbook (excel format).</p>
  
  <pre><code>require 'rubygems'
  require 'csv'
  require 'spreadsheet'
  
  csv_fname = 'commissions.csv'
  
  options = { headers: :first_row }
  
  food_type = { 'food' =&gt; 'butter'}
  
  food_type_match = nil
  
  CSV.open(csv_fname, 'r', options) do |csv|
    food_type_match = csv.find_all do |row|
      Hash[row].select { |k,v| food_type[k] } == food_type
    end
  end
  
  #writing the 'butter' data to a CSV file
  #CSV.open('butter.csv', 'w') do |csv_object|
  # food_type_match.each do |row_array|
  #   csv_object &lt;&lt; row_array
  # end
  #end
  
  book = Spreadsheet::Workbook.new
  sheet1 = book.create_worksheet
  
  food_type_match.each do |csv|
    csv.each_with_index do |row, i|
      sheet1.row(i).replace(row)
    end
  end
  </code></pre>
  
  <p>The spreadsheet generates but comes out blank. I have searched through numerous topics on ruby spreadsheet but I cannot get it to work. Any help would be greatly appreciated.</p>