From: "robertgleeson (Robert Gleeson)" Date: 2013-07-25T10:44:08+09:00 Subject: [ruby-core:56165] [ruby-trunk - Feature #8683] CSV library can't append to the current row. It should be able to. Issue #8683 has been updated by robertgleeson (Robert Gleeson). @nobu Thanks! I've re-created an example using CSV::Table: require "csv" row = CSV::Row.new ["Name"], ["Name"], true table = CSV::Table.new [row] table[0] << ["Hair Color", "Hair Color"] p table.to_csv It works like I want, but CSV::Row has a strange API. Why does it have a concept of a header, and try to map it to a value, as if it were a Hash? Couldn't it just be a row of values with no header? And if it is being treated like a Hash, why isn't the argument just :header => :value? instead of [:header], [:value] ? It looks like it even has a method called field(), which may as well be Hash#fetch. This isn't a bug anymore, but I am curious why it works like that. My problem is solved, so thanks again. ---------------------------------------- Feature #8683: CSV library can't append to the current row. It should be able to. https://bugs.ruby-lang.org/issues/8683#change-40658 Author: robertgleeson (Robert Gleeson) Status: Rejected Priority: Normal Assignee: Category: Target version: The CSV library can only add *new* rows, and it provides no way to update the current row after it has been created. For example: CSV.generate headers: true do |csv| csv << ["one"] ["two", "three"].each do |e| csv << e # This creates a new row, I want to append. end csv.headers << ["two", "three"] # No, this doesn't work either. end Is this possible? I find it hard to believe the API could be _that_ limited and inflexible. -- http://bugs.ruby-lang.org/