るりまサーチ

最速Rubyリファレンスマニュアル検索!
48件ヒット [1-48件を表示] (0.084秒)

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

クラス

キーワード

検索結果

CSV::Table#each {|column_name, values| ... } -> self (21141.0)

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

...ist[例 ロウモード][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"])
t
able = CSV::Table.new([row1, row2, row3])
t
able.each {...
...#<CSV::Row "header1":"row1_1" "header2":"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::R...
...ow.new(["header1", "header2"], ["row2_1", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
t
able = CSV::Table.new([row1, row2, row3])
t
able.by_col!
t
able.each { |column_name, values| print column_name, values, "\n" }

# => header1["row1_1", "row2_1", "row3_1"]
# => header...

CSV::Table#each {|row| ... } -> self (21141.0)

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

...ist[例 ロウモード][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"])
t
able = CSV::Table.new([row1, row2, row3])
t
able.each {...
...#<CSV::Row "header1":"row1_1" "header2":"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::R...
...ow.new(["header1", "header2"], ["row2_1", "row2_2"])
row3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
t
able = CSV::Table.new([row1, row2, row3])
t
able.by_col!
t
able.each { |column_name, values| print column_name, values, "\n" }

# => header1["row1_1", "row2_1", "row3_1"]
# => header...

CSV#force_quotes? -> bool (6139.0)

出力される全てのフィールドがクオートされる場合は、真を返します。

...st[例][ruby]{
require "csv"

rows = [["header1", "header2"], ["row1_1,", "row1_2"]]
result = CSV.generate(force_quotes: false) do |csv|
rows.each { |row| csv << row }
csv
.force_quotes? # => false
end
print result

# => header1,header2
# "row1_1,",row1_2
//}

//emlist[例][ruby]{
require "csv...
..."

rows = [["header1", "header2"], ["row1_1,", "row1_2"]]
result = CSV.generate(force_quotes: true) do |csv|
rows.each { |row| csv << row }
csv
.force_quotes? # => true
end
print result

# => true
# => "header1","header2"
# "row1_1,","row1_2"
//}

@see CSV.new...

CSV::Table#push(*rows) -> self (3033.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)
t
able = csv.read
rows = [
CSV
::Row.new(table.headers, [4, 5, 6]),
[7, 8, 9]
]

t
able.pu...
...sh(*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#<<...