End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
CSV::Table#push
table.push(*rows_or_arrays) → self
lib/csv/table.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/csv/table.rb, line 788
def push(*rows)
rows.each { |row| self << row }
self # for chaining
end
A shortcut for appending multiple rows. Equivalent to:
Example
rows.each {|row| self << row }
Each argument may be either a CSV::Row object or an Array:
Example
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" table = CSV.parse(source, headers: true) rows = [ CSV::Row.new(table.headers, ['bat', 3]), ['bam', 4] ] table.push(*rows) table[3..4] # => [#<CSV::Row "Name":"bat" "Value":3>, #<CSV::Row "Name":"bam" "Value":4>]