るりまサーチ

最速Rubyリファレンスマニュアル検索!
36件ヒット [1-36件を表示] (0.012秒)
トップページ > クエリ:row[x] > クエリ:filter[x]

別のキーワード

  1. matrix row
  2. csv header_row?
  3. row []=
  4. csv row_sep
  5. csv row

ライブラリ

クラス

検索結果

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...