るりまサーチ

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

別のキーワード

  1. stringio read
  2. _builtin read
  3. io read
  4. csv read
  5. tuple read

ライブラリ

キーワード

検索結果

CSV::Table#empty? -> bool (13.0)

ヘッダーを除いて、データがないときに true を返します。

...ーを除いて、データがないときに true を返します。

Array#empty? に委譲しています。

//emlist[][ruby]{
require 'csv'
csv = CSV.new("a,b\n", headers: true)
table = csv.read
p table.empty? # => true
table << [1, 2]
p table.empty? # => false
//}

@see Array#empty?...

CSV::Table#push(*rows) -> self (13.0)

複数の行を追加するためのショートカットです。

...と同じです。
//emlist[][ruby]{
rows.each {|row| self << row }
//}

@param rows CSV::Row のインスタンスか配列を指定します。

//emlist[例][ruby]{
require 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
table = csv.read
rows = [
CSV::Row.new(table.headers, [4, 5, 6]),
[7,...
...8, 9]
]

table.push(*rows)
p table[0..2]
# => [#<CSV::Row "a":"1" "b":"2" "c":"3">, #<CSV::Row "a":4 "b":5 "c":6>, #<CSV::Row "a":7 "b":8 "c":9>]
//}

@see CSV::Table#<<...