End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
CSV#header_row?
csv.header_row? → true or false
lib/csv.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/lib/csv.rb, line 2630
def header_row?
parser.header_row?
end
Returns true if the next row to be read is a header row\; false otherwise.
Without headers:
Example
string = "foo,0\nbar,1\nbaz,2\n" csv = CSV.new(string) csv.header_row? # => false
With headers:
Example
string = "Name,Value\nfoo,0\nbar,1\nbaz,2\n" csv = CSV.new(string, headers: true) csv.header_row? # => true csv.shift # => #<CSV::Row "Name":"foo" "Value":"0"> csv.header_row? # => false
Raises an exception if the source is not opened for reading:
Example
string = "foo,0\nbar,1\nbaz,2\n" csv = CSV.new(string) csv.close # Raises IOError (not opened for reading) csv.header_row?