36件ヒット
[1-36件を表示]
(0.012秒)
検索結果
先頭3件
-
CSV
. filter(input , options = Hash . new) {|row| . . . } (18326.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
...ut_row_sep" のデフォルト値は $/ です。
//emlist[例: input, output は初期値][ruby]{
# $ echo "header1,header2\nrow1_1,row1_2" > in.csv; ruby test.rb in.csv
require "csv"
options = { headers: true, return_headers: true, write_headers: true }
CSV.filter(options) do |row|
if row.he......ader_row?
row << "header3"
next
end
row << "row1_3"
end
# => header1,header2,header3
# row1_1,row1_2,row1_3
//}
//emlist[例: input, output を指定する][ruby]{
require "csv"
content = <<EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21......headers: 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 n... -
CSV
. filter(input , output , options = Hash . new) {|row| . . . } (18326.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
...ut_row_sep" のデフォルト値は $/ です。
//emlist[例: input, output は初期値][ruby]{
# $ echo "header1,header2\nrow1_1,row1_2" > in.csv; ruby test.rb in.csv
require "csv"
options = { headers: true, return_headers: true, write_headers: true }
CSV.filter(options) do |row|
if row.he......ader_row?
row << "header3"
next
end
row << "row1_3"
end
# => header1,header2,header3
# row1_1,row1_2,row1_3
//}
//emlist[例: input, output を指定する][ruby]{
require "csv"
content = <<EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21......headers: 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 n... -
CSV
. filter(options = Hash . new) {|row| . . . } (18326.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
...ut_row_sep" のデフォルト値は $/ です。
//emlist[例: input, output は初期値][ruby]{
# $ echo "header1,header2\nrow1_1,row1_2" > in.csv; ruby test.rb in.csv
require "csv"
options = { headers: true, return_headers: true, write_headers: true }
CSV.filter(options) do |row|
if row.he......ader_row?
row << "header3"
next
end
row << "row1_3"
end
# => header1,header2,header3
# row1_1,row1_2,row1_3
//}
//emlist[例: input, output を指定する][ruby]{
require "csv"
content = <<EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21......headers: 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 n...