3件ヒット
[1-3件を表示]
(0.141秒)
ライブラリ
- csv (3)
検索結果
先頭3件
-
CSV
:: Table # delete _ if {|column _ name , values| . . . } -> self (81829.0) -
ブロックを評価した結果が真である行か列を削除します。
...id"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "invalid"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "valid"])
table = CSV::Table.new([row1, row2, row3])
table.delete_if { |row| row["header2"] == "invalid" }
table.to_a # => [["header1", "header2"], ["row1_1", "valid"], ["r......V::Row.new(["id", "name"], [2, "suzuki"])
row3 = CSV::Row.new(["id", "name"], [3, "sato"])
table = CSV::Table.new([row1, row2, row3])
table.by_col!
table.delete_if { |column_name, values| column_name == "id" }
table.to_a # => [["name"], ["tanaka"], ["suzuki"], ["sato"]]
//}
@see CSV::Table#delete... -
CSV
:: Table # delete _ if {|row| . . . } -> self (81829.0) -
ブロックを評価した結果が真である行か列を削除します。
...id"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "invalid"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "valid"])
table = CSV::Table.new([row1, row2, row3])
table.delete_if { |row| row["header2"] == "invalid" }
table.to_a # => [["header1", "header2"], ["row1_1", "valid"], ["r......V::Row.new(["id", "name"], [2, "suzuki"])
row3 = CSV::Row.new(["id", "name"], [3, "sato"])
table = CSV::Table.new([row1, row2, row3])
table.by_col!
table.delete_if { |column_name, values| column_name == "id" }
table.to_a # => [["name"], ["tanaka"], ["suzuki"], ["sato"]]
//}
@see CSV::Table#delete... -
CSV
:: Table # delete(index _ or _ header) -> object (27487.0) -
指定された行か列を削除して返します。
...更したい場合は CSV::Table#by_col!,
CSV::Table#by_row! を使用してください。
//emlist[例][ruby]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
table = CSV::Table.new([row1, row2])
ta......ble.delete(1)
table.to_a # => [["header1", "header2"], ["row1_1", "row1_2"]]
//}
@see CSV::Table#by_col!, CSV::Table#by_row!, CSV::Table#delete_if...