156件ヒット
[1-100件を表示]
(0.014秒)
ライブラリ
- csv (156)
クラス
-
CSV
:: Table (156)
キーワード
- [] (36)
- []= (12)
-
by
_ col _ or _ row (12) -
by
_ col _ or _ row! (12) -
delete
_ if (24) - each (24)
- mode (12)
-
values
_ at (12)
検索結果
先頭5件
-
CSV
:: Table # by _ col! -> self (18191.0) -
自身をカラムモードに変更します。
...。
//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])
table.by_col!
table[0] # => ["row1_1", "row2_1"]
table[1] # => ["row1_2", "row2_2"]
//}... -
CSV
:: Table # by _ col _ or _ row -> CSV :: Table (6209.0) -
ミックスモードになっている新しい CSV::Table オブジェクトを返します。
...e "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]).by_col!
table # => #<CSV::Table mode:col row_count:3>
col_or_row_table = table.by_col_or_row
col_or_row_table......# => #<CSV::Table mode:col_or_row row_count:3>
table # => #<CSV::Table mode:col row_count:3>
//}... -
CSV
:: Table # by _ col _ or _ row! -> self (6191.0) -
自身をミックスモードに変更します。
...][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]).by_col!
table # => #<CSV::Table mode:col row_count:3>
table.by_col_or_row!
table #......=> #<CSV::Table mode:col_or_row row_count:3>
//}... -
CSV
:: Table # [](index) -> CSV :: Row | [String] | nil (408.0) -
ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。
...名前を指定すれば列単位で動作します。
このメソッドを呼び出す前に CSV::Table#by_col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。
@param index ミックスモード・ロウモー......
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])
# ミックスモード
p table.mode # => :col_or_row
p table[0] # => #<CSV::Row "header1":"row1_1" "header2":"row......e[1] # => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
p table["header2"] # => ["row1_2", "row2_2"]
p table[0..1] # => [#<CSV::Row "header1":"row1_1" "header2":"row1_2">, #<CSV::Row "header1":"row2_1" "header2":"row2_2">]
# カラムモード
table.by_col!
p table.mode # =>... -
CSV
:: Table # [](range) -> [CSV :: Row]| [Array] | nil (408.0) -
ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。
...名前を指定すれば列単位で動作します。
このメソッドを呼び出す前に CSV::Table#by_col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。
@param index ミックスモード・ロウモー......
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])
# ミックスモード
p table.mode # => :col_or_row
p table[0] # => #<CSV::Row "header1":"row1_1" "header2":"row......e[1] # => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
p table["header2"] # => ["row1_2", "row2_2"]
p table[0..1] # => [#<CSV::Row "header1":"row1_1" "header2":"row1_2">, #<CSV::Row "header1":"row2_1" "header2":"row2_2">]
# カラムモード
table.by_col!
p table.mode # =>... -
CSV
:: Table # each {|row| . . . } -> self (389.0) -
デフォルトのミックスモードかロウモードでは、行単位で繰り返します。カラ ムモードでは、ブロックに列名と対応する値の配列を与え、列単位で繰り返し ます。
...e "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
table = CSV::Table.new([row1, row2, row3])
table.each { |row| p row }
# => #<CSV::Row "heade......":"row1_2">
# => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
# => #<CSV::Row "header1":"row3_1" "header2":"row3_2">
//}
//emlist[例 カラムモード][ruby]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1......", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
table = CSV::Table.new([row1, row2, row3])
table.by_col!
table.each { |column_name, values| print column_name, values, "\n" }
# => header1["row1_1", "row2_1", "row3_1"]
# => header2["row1_2", "row2_2", "row3_2"]
//}... -
CSV
:: Table # [](header) -> [String] | [nil] (308.0) -
ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。
...名前を指定すれば列単位で動作します。
このメソッドを呼び出す前に CSV::Table#by_col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。
@param index ミックスモード・ロウモー......
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])
# ミックスモード
p table.mode # => :col_or_row
p table[0] # => #<CSV::Row "header1":"row1_1" "header2":"row......e[1] # => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
p table["header2"] # => ["row1_2", "row2_2"]
p table[0..1] # => [#<CSV::Row "header1":"row1_1" "header2":"row1_2">, #<CSV::Row "header1":"row2_1" "header2":"row2_2">]
# カラムモード
table.by_col!
p table.mode # =>... -
CSV
:: Table # each {|column _ name , values| . . . } -> self (289.0) -
デフォルトのミックスモードかロウモードでは、行単位で繰り返します。カラ ムモードでは、ブロックに列名と対応する値の配列を与え、列単位で繰り返し ます。
...e "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
table = CSV::Table.new([row1, row2, row3])
table.each { |row| p row }
# => #<CSV::Row "heade......":"row1_2">
# => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
# => #<CSV::Row "header1":"row3_1" "header2":"row3_2">
//}
//emlist[例 カラムモード][ruby]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row2 = CSV::Row.new(["header1", "header2"], ["row2_1......", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
table = CSV::Table.new([row1, row2, row3])
table.by_col!
table.each { |column_name, values| print column_name, values, "\n" }
# => header1["row1_1", "row2_1", "row3_1"]
# => header2["row1_2", "row2_2", "row3_2"]
//}... -
CSV
:: Table # delete _ if {|row| . . . } -> self (257.0) -
ブロックを評価した結果が真である行か列を削除します。
...]{
require "csv"
row1 = CSV::Row.new(["header1", "header2"], ["row1_1", "valid"])
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"] ==......"], ["row1_1", "valid"], ["row3_1", "valid"]]
//}
//emlist[例 カラムモード][ruby]{
require "csv"
row1 = CSV::Row.new(["id", "name"], [1, "tanaka"])
row2 = CSV::Row.new(["id", "name"], [2, "suzuki"])
row3 = CSV::Row.new(["id", "name"], [3, "sato"])
table = CSV::Table.new([row1, row2, row3])
t...