title: How to write columns header to a csv file with Ruby?
body: <p>I am having trouble writing columns to a csv file with Ruby. Below is my snippet of code.</p>
  
  <pre><code> calc = numerator/denominator.to_f
   data_out = "#{numerator}, #{denominator}, #{calc}"
   File.open('cdhu3_X.csv','a+') do|hdr|
        hdr &lt;&lt; ["numerator","denominator","calculation\n"] #&lt; column header
            hdr &lt;&lt; "#{data_out}\n"
   end
  </code></pre>
  
  <p>The code adds the column headers to every line and I only need it at the top of each column of data.  I have searched here and other places but can't find a clear answer to how its done.
  Any help would be greatly appreciated.</p>