44件ヒット
[1-44件を表示]
(0.041秒)
別のキーワード
クラス
- CSV (11)
-
CSV
:: Table (33)
キーワード
-
force
_ quotes? (11) - push (11)
検索結果
先頭4件
-
CSV
:: Table # each {|column _ name , values| . . . } -> self (21116.0) -
デフォルトのミックスモードかロウモードでは、行単位で繰り返します。カラ ムモードでは、ブロックに列名と対応する値の配列を与え、列単位で繰り返し ます。
...uby]{
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.each { |row| p row }
# => #<CSV......_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::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... -
CSV
:: Table # each {|row| . . . } -> self (21116.0) -
デフォルトのミックスモードかロウモードでは、行単位で繰り返します。カラ ムモードでは、ブロックに列名と対応する値の配列を与え、列単位で繰り返し ます。
...uby]{
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.each { |row| p row }
# => #<CSV......_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::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... -
CSV
:: Table # push(*rows) -> self (3032.0) -
複数の行を追加するためのショートカットです。
...mlist[][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#<<... -
CSV
# force _ quotes? -> bool (114.0) -
出力される全てのフィールドがクオートされる場合は、真を返します。
...][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"
row......s = [["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...