Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

CSV::Row#to_csv

row.to_csv → csv_string

Returns the row as a CSV String. Headers are not included:

Example
source = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
table = CSV.parse(source, headers: true)
row = table[0]
row.to_csv # => "foo,0\n"
See also #push #to_h #member? #to_hash also in 3.3 · 3.2 · 3.1