るりまサーチ

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

別のキーワード

  1. csv header_convert
  2. csv header_row?
  3. mkmf have_header
  4. cgi header
  5. csv header_converters

ライブラリ

クラス

検索結果

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

絞り込み条件を変える