Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

class method

CSV.table

CSV.table(source, **options)

Calls CSV.read with source, options, and certain default options:

Returns a CSV::Table object.

Example:

Example
string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n"
path = 't.csv'
File.write(path, string)
CSV.table(path) # => #<CSV::Table mode:col_or_row row_count:4>
See also .readlines #<< .read #add_row also in 3.2 · 3.1 · 3.0