title: Parse CSV file with header fields as attributes for each row
body: <p>I would like to parse a CSV file so that each row is treated like an object with the header-row being the names of the attributes in the object.  I could write this, but I'm sure its already out there.</p>
  
  <p>Here is my CSV input:</p>
  
  <pre><code>"foo","bar","baz"
  1,2,3
  "blah",7,"blam"
  4,5,6
  </code></pre>
  
  <p>The code would look something like this:</p>
  
  <pre><code>CSV.open('my_file.csv','r') do |csv_obj|
    puts csv_obj.foo   #prints 1 the 1st time, "blah" 2nd time, etc
    puts csv.bar       #prints 2 the first time, 7 the 2nd time, etc
  end
  </code></pre>
  
  <p>With Ruby's CSV module I believe I can only access the fields by index. I think the above code would be a bit more readable.  Any ideas?</p>