るりまサーチ

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

別のキーワード

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

クラス

キーワード

検索結果

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

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

...ist[例 ロウモード][ruby]{
r
equire "csv"

r
ow1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row1_2"])
r
ow2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
r
ow3 = CSV::Row.new(["header1", "header2"], ["row3_1", "row3_2"])
t
able = CSV::Table.new([row1, row2, row3])
t
able.each {...
...|row| p row }

# => #<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]{
r
equire "csv"

r
ow1 = CSV::Row.new(["header1", "header2"], ["row1_1", "row...
..."])
r
ow2 = CSV::Row.new(["header1", "header2"], ["row2_1", "row2_2"])
r
ow3 = 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", "row...

CSV#force_quotes? -> bool (12227.0)

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

...st[例][ruby]{
r
equire "csv"

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

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

//emlist[例][ruby]{
r
equire "csv...
..."

r
ows = [["header1", "header2"], ["row1_1,", "row1_2"]]
r
esult = CSV.generate(force_quotes: true) do |csv|
r
ows.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 (3121.0)

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

...ist[][ruby]{
r
ows.each {|row| self << row }
//}

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

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

t
able.push(*ro...
...ws)
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#<<...