title: no implicit conversion of nil into String error
body: <p>I have a ruby script that will create two files by taking and merging values from another file.</p>
  
  <pre><code>#Resources
  require 'rubygems'
  require 'csv'
  
  col_date = []
  col_constant1 = []
  col_constant2 = []
  col_appYear = []
  col_statsDesc = []
  col_keyStats =[]
  col_weeklyTotal=[]
  
  
  weekly_total = []
  
  fname = "finalStats.csv" #variable for capture file
          finalStatsFile = File.open(fname, "w") #write to capture file
  fname2 = "weeklyStats.csv"
          weeklyStatsFile = File.open(fname2, "w")    
  CSV.foreach('compareData.csv', converters: :numeric) do |row|
      weekly_total &lt;&lt; row[0] - row[1]
  
      weekly_total.each do |data| 
      data &lt;&lt; weekly_total.shift 
       weeklyStatsFile.puts data
  end 
  end
  
  #retrieve stats from original document 
   CSV.foreach("autoCapture.csv") {|row| col_date &lt;&lt; row[0]}
   CSV.foreach("autoCapture.csv") {|row| col_constant1 &lt;&lt; row[1]}
   CSV.foreach("autoCapture.csv") {|row| col_appYear &lt;&lt; row[2]}
   CSV.foreach("autoCapture.csv") {|row| col_statsDesc &lt;&lt; row[3]}
   CSV.foreach("autoCapture.csv") {|row| col_constant2 &lt;&lt; row[4]}
   CSV.foreach("autoCapture.csv") {|row| col_keyStats &lt;&lt; row[5]}
   CSV.foreach("weeklyStats.csv") {|row| col_weeklyTotal &lt;&lt; row[0]}
  
  
  
    col_date.zip(col_constant1, col_appYear, col_statsDesc, col_constant2, col_keyStats, col_weeklyTotal).each do |col_date, col_constant1, col_appYear, col_statsDesc, col_constant2, 
    col_keyStats, col_weeklyTotal|
  
    finalStatsFile.puts col_date+", "+col_constant1+", "+ col_appYear+", "+col_statsDesc+", "+col_constant2+", "+col_keyStats+", "+col_weeklyTotal
  
   end
  </code></pre>
  
  <p>In one file I wish to subtract the values in row[1] from the values in row[0] to create a new 'weekly_total' value. I then output this array of values in a file called weeklyStats.csv. This will output a column of values fine.</p>
  
  <p>However, I want to join these values with another set from another file (autoCapture.csv) and when I try to zip them as arrays so that they read across in corresponding rows I get the error:</p>
  
  <pre><code>weeklyStats_csv.rb:42:in `+': no implicit conversion of nil into String (TypeError)
      from weeklyStats_csv.rb:42:in `block in &lt;main&gt;'
      from weeklyStats_csv.rb:40:in `each'
      from weeklyStats_csv.rb:40:in `&lt;main&gt;'
  </code></pre>
  
  <p>I gather this means that the array zip will not catch an exception if the one of the values is nil and therefore cannot convert to string. The problem is, I have tried converting weekly_total to string and array as I thought that it may be the problem (a mismatch of types) but I just dont where to go from here. Can anyone help?</p>