55件ヒット
[1-55件を表示]
(0.027秒)
検索結果
先頭5件
-
CSV
:: Row # header _ row? -> bool (18125.0) -
ヘッダ行であれば真を返します。そうでなければ偽を返します。
...行であれば真を返します。そうでなければ偽を返します。
//emlist[例][ruby]{
require "csv"
header_row = CSV::Row.new(["header1", "header2"], [], true)
row = CSV::Row.new(["header1", "header2"], [1, 2])
header_row.header_row? # => true
row.header_row? # => false
//}... -
CSV
# header _ row? -> bool (18119.0) -
次に読み込まれる行が、ヘッダである場合に真を返します。 そうでない場合は、偽を返します。
...に読み込まれる行が、ヘッダである場合に真を返します。
そうでない場合は、偽を返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true)
csv.header_row? # => true
csv.readline
csv.header_row? # => false
//}... -
CSV
. filter(input , options = Hash . new) {|row| . . . } (121.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
...uby test.rb in.csv
require "csv"
options = { headers: true, return_headers: true, write_headers: true }
CSV.filter(options) do |row|
if row.header_row?
row << "header3"
next
end
row << "row1_3"
end
# => header1,header2,header3
# row1_1,row1_2,row1_3
//}
//emlist[例: input, output......ders: true, return_headers: true, write_headers: true }
CSV.filter(File.open("test.csv"), File.open("out.csv", "w"), options) do |row|
if row.header_row?
row << "full name"
next
end
row << row["first name"] + " " + row["last name"]
end
# out.csv の内容
# => id,first name,last name......,age,full name
# 1,taro,tanaka,20,taro tanaka
# 2,jiro,suzuki,18,jiro suzuki
# 3,ami,sato,19,ami sato
# 4,yumi,adachi,21,yumi adachi
//}
@see CSV.new... -
CSV
. filter(input , output , options = Hash . new) {|row| . . . } (121.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
...uby test.rb in.csv
require "csv"
options = { headers: true, return_headers: true, write_headers: true }
CSV.filter(options) do |row|
if row.header_row?
row << "header3"
next
end
row << "row1_3"
end
# => header1,header2,header3
# row1_1,row1_2,row1_3
//}
//emlist[例: input, output......ders: true, return_headers: true, write_headers: true }
CSV.filter(File.open("test.csv"), File.open("out.csv", "w"), options) do |row|
if row.header_row?
row << "full name"
next
end
row << row["first name"] + " " + row["last name"]
end
# out.csv の内容
# => id,first name,last name......,age,full name
# 1,taro,tanaka,20,taro tanaka
# 2,jiro,suzuki,18,jiro suzuki
# 3,ami,sato,19,ami sato
# 4,yumi,adachi,21,yumi adachi
//}
@see CSV.new... -
CSV
. filter(options = Hash . new) {|row| . . . } (121.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
...uby test.rb in.csv
require "csv"
options = { headers: true, return_headers: true, write_headers: true }
CSV.filter(options) do |row|
if row.header_row?
row << "header3"
next
end
row << "row1_3"
end
# => header1,header2,header3
# row1_1,row1_2,row1_3
//}
//emlist[例: input, output......ders: true, return_headers: true, write_headers: true }
CSV.filter(File.open("test.csv"), File.open("out.csv", "w"), options) do |row|
if row.header_row?
row << "full name"
next
end
row << row["first name"] + " " + row["last name"]
end
# out.csv の内容
# => id,first name,last name......,age,full name
# 1,taro,tanaka,20,taro tanaka
# 2,jiro,suzuki,18,jiro suzuki
# 3,ami,sato,19,ami sato
# 4,yumi,adachi,21,yumi adachi
//}
@see CSV.new...