168件ヒット
[1-100件を表示]
(0.057秒)
種類
- インスタンスメソッド (96)
- 特異メソッド (60)
- 定数 (12)
ライブラリ
- csv (168)
キーワード
-
DEFAULT
_ OPTIONS (12) - filter (24)
- flush (12)
-
force
_ quotes? (12) - foreach (12)
- headers (12)
- instance (24)
- puts (12)
-
quote
_ char (12) -
return
_ headers? (12) - truncate (12)
-
unconverted
_ fields? (12)
検索結果
先頭5件
-
CSV
# flush -> self (6101.0) -
IO#flush に委譲します。
...IO#flush に委譲します。... -
CSV
# force _ quotes? -> bool (6101.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... -
CSV
# quote _ char -> String (6101.0) -
フィールドをクオートするのに使用する文字列を返します。
...フィールドをクオートするのに使用する文字列を返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", quote_char: "'")
csv.quote_char # => "'"
//}
@see CSV.new... -
CSV
# return _ headers? -> bool (6101.0) -
ヘッダを返す場合は、真を返します。 そうでない場合は、偽を返します。
...[ruby]{
require "csv"
csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true, return_headers: false)
csv.return_headers? # => false
csv.shift # => #<CSV::Row "header1":"row1_1" "header2":"row1_2">
csv = CSV.new("header1,header2\nrow1_1,row1_2", headers: true, return_headers: true)
csv.retur......n_headers? # => true
csv.shift # => #<CSV::Row "header1":"header1" "header2":"header2">
//}
@see CSV.new... -
CSV
# truncate(path , length) -> 0 (6101.0) -
File#truncate に委譲します。
...File#truncate に委譲します。
@see File#truncate... -
CSV
# unconverted _ fields? -> bool (6101.0) -
パースした結果が unconverted_fields というメソッドを持つ場合に真を返します。 そうでない場合は、偽を返します。
...スした結果が unconverted_fields というメソッドを持つ場合に真を返します。
そうでない場合は、偽を返します。
//emlist[例][ruby]{
require "csv"
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10")
csv.unconverted_fields? # => nil
csv = CSV.new("date1,date2\n2......018-07-09,2018-07-10", unconverted_fields: false)
csv.unconverted_fields? # => false
csv = CSV.new("date1,date2\n2018-07-09,2018-07-10", headers: true, unconverted_fields: true)
csv.unconverted_fields? # => true
csv.convert(:date)
row = csv.readline
row.fields # => [#<Date: 2018-07-09 (......(2458309j,0s,0n),+0s,2299161j)>, #<Date: 2018-07-10 ((2458310j,0s,0n),+0s,2299161j)>]
row.unconverted_fields # => ["2018-07-09", "2018-07-10"]
//}
@see CSV.new... -
CSV
:: DEFAULT _ OPTIONS -> Hash (6101.0) -
このオプションは呼び出し側で上書きしなかったときに使用するオプションです。
...るオプションです。
: :col_sep
","
: :row_sep
:auto
: :quote_char
'"'
: :field_size_limit
nil
: :converters
nil
: :unconverted_fields
nil
: :headers
false
: :return_headers
false
: :header_converters
nil
: :skip_blanks
false
: :force_quotes
false
: :skip_lines
nil... -
CSV
# puts(row) -> self (3101.0) -
自身に row を追加します。
...m row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値
のみが追加されます。
//emlist[例 配列を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name......2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
csv.puts(["5", "saburo", "kondo", "34"])
end
print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo....../emlist[例 CSV::Row を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kond... -
CSV
. filter(input , output , options = Hash . new) {|row| . . . } (301.0) -
このメソッドは CSV データに対して Unix のツール群のようなフィルタを構築 するのに便利です。
... CSV データに対して Unix のツール群のようなフィルタを構築
するのに便利です。
与えられたブロックに一行ずつ渡されます。ブロックに渡された行は必要であ
れば変更することができます。ブロックの評価後に行を全て ou......ut に書き込
みます。
@param input String か IO のインスタンスを指定します。
デフォルトは ARGF です。
@param output String か IO のインスタンスを指定します。
デフォルトは $stdout です。
@param options ":in_", ":inpu......nput にだけ適用されます。
":out_", ":output_" で始まるキーは output にだけ適用されます。
それ以外のキーは両方に適用されます。
":output_row_sep" のデフォルト値は $/ です。
//emlist[例: input, output...