Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > csvライブラリ > CSV::Rowクラス > to_hash

instance method CSV::Row#to_hash

to_hash -> Hash[permalink][rdoc]

自身をシンプルなハッシュに変換します。

フィールドの順序は無視されます。重複したフィールドは削除されます。



require "csv"

row = CSV::Row.new(["header2", "header1", "header2"], [1, 2, 3])
row.to_hash # => {"header2"=>3, "header1"=>2}