るりまサーチ

最速Rubyリファレンスマニュアル検索!
396件ヒット [1-100件を表示] (0.014秒)
トップページ > クエリ:row[x] > クエリ:Table[x]

別のキーワード

  1. matrix row
  2. csv header_row?
  3. row []=
  4. csv row
  5. csv row_sep

ライブラリ

クラス

キーワード

検索結果

<< 1 2 3 ... > >>

CSV::Table (18028.0)

CSV::Table は CSV ドキュメントを表す二次元のデータ構造です。 行単位や列単位の操作を行うことが出来ます。また必要であれば CSV に 戻すこともできます。

...CSV::Table は CSV ドキュメントを表す二次元のデータ構造です。
行単位や列単位の操作を行うことが出来ます。また必要であれば CSV に
戻すこともできます。

ヘッダ行の処理が有効である場合、CSV から返されるテーブルは全...
...ードがあります。

: :col_or_row
デフォルトはこのモードです。このマニュアル内ではミックスモードと呼んでいます。
行単位でアクセスするか列単位でアクセスするか自動的に判断します。
: :row
ロウモード。テーブル...

CSV::Table#by_row -> CSV::Table (9416.0)

ロウモードになっている新しい CSV::Table オブジェクトを返します。

...ロウモードになっている新しい CSV::Table オブジェクトを返します。

元のテーブルモードを変更せずにメソッドチェーンできるので便利です。しか
し、大きなデータセットに対しても同じだけメモリを消費するので気をつ...
..."csv"

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
table
= CSV::Table.new([row1, row2])
table
# => #<CSV::Table mode:col_or_row row_count:3>
row
_table = table.by_row # => #<CSV::Table mode:row row_count...
...:3>
row_table[0] # => #<CSV::Row "header1":"row1_1" "header2":"row1_2">
row
_table[1] # => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
//}...

CSV::Table#by_col_or_row -> CSV::Table (9380.0)

ミックスモードになっている新しい CSV::Table オブジェクトを返します。

...ミックスモードになっている新しい CSV::Table オブジェクトを返します。

元のテーブルモードを変更せずにメソッドチェーンできるので便利です。しか
し、大きなデータセットに対しても同じだけメモリを消費するので気...
...csv"

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = 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_row! -> self (9281.0)

自身をロウモードに変更します。

..."csv"

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
table
= CSV::Table.new([row1, row2])
table
# => #<CSV::Table mode:col_or_row row_count:3>
table
.by_row!
table
# => #<CSV::Table mode:row row_coun...
...t:3>
table[0] # => #<CSV::Row "header1":"row1_1" "header2":"row1_2">
table
[1] # => #<CSV::Row "header1":"row2_1" "header2":"row2_2">
//}...

CSV::Table#by_col_or_row! -> self (9227.0)

自身をミックスモードに変更します。

...csv"

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = 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 mo...
...de:col_or_row row_count:3>
//}...

絞り込み条件を変える

CSV::Table#[](index) -> CSV::Row | [String] | nil (3522.0)

ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。

...の名前を指定すれば列単位で動作します。

このメソッドを呼び出す前に CSV::Table#by_col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。

@param index ミックスモード・ロウモ...
...

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = 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...
..._2">
p table[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 (3522.0)

ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。

...の名前を指定すれば列単位で動作します。

このメソッドを呼び出す前に CSV::Table#by_col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。

@param index ミックスモード・ロウモ...
...

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = 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...
..._2">
p table[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 (3425.0)

デフォルトのミックスモードかロウモードでは、行単位で繰り返します。カラ ムモードでは、ブロックに列名と対応する値の配列を与え、列単位で繰り返し ます。

...e "csv"

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
row
3 = 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"

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = CSV::Row.new(["header1", "header2"], ["row2_1...
...", "row2_2"])
row
3 = 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] (3422.0)

ミックスモードでは、このメソッドは引数に行番号を指定すれば行単位で動作 し、ヘッダの名前を指定すれば列単位で動作します。

...の名前を指定すれば列単位で動作します。

このメソッドを呼び出す前に CSV::Table#by_col! を呼び出すとカラム
モードになります。また CSV::Table#by_row! を呼び出すとロウモード
になります。

@param index ミックスモード・ロウモ...
...

row
1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
row
2 = 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...
..._2">
p table[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...
<< 1 2 3 ... > >>