33件ヒット
[1-33件を表示]
(0.069秒)
検索結果
先頭3件
-
CSV
. instance(data = $ stdout , options = Hash . new) -> CSV (6408.0) -
このメソッドは CSV.new のように CSV のインスタンスを返します。 しかし、返される値は Object#object_id と与えられたオプションを キーとしてキャッシュされます。
...このメソッドは CSV.new のように CSV のインスタンスを返します。
しかし、返される値は Object#object_id と与えられたオプションを
キーとしてキャッシュされます。
ブロックが与えられた場合、生成されたインスタンスをブ......す。
@param data String か IO のインスタンスを指定します。
@param options CSV.new のオプションと同じオプションを指定できます。
//emlist[例][ruby]{
require "csv"
options = { headers: true }
text =<<-EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,s......uzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
csv = CSV.instance(text, options)
csv2 = CSV.instance(text, options)
csv.object_id == csv2.object_id # => true
print csv.read
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
//}
@see CSV.new... -
CSV
. instance(data = $ stdout , options = Hash . new) {|csv| . . . } -> object (6408.0) -
このメソッドは CSV.new のように CSV のインスタンスを返します。 しかし、返される値は Object#object_id と与えられたオプションを キーとしてキャッシュされます。
...このメソッドは CSV.new のように CSV のインスタンスを返します。
しかし、返される値は Object#object_id と与えられたオプションを
キーとしてキャッシュされます。
ブロックが与えられた場合、生成されたインスタンスをブ......す。
@param data String か IO のインスタンスを指定します。
@param options CSV.new のオプションと同じオプションを指定できます。
//emlist[例][ruby]{
require "csv"
options = { headers: true }
text =<<-EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,s......uzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS
csv = CSV.instance(text, options)
csv2 = CSV.instance(text, options)
csv.object_id == csv2.object_id # => true
print csv.read
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
//}
@see CSV.new... -
CSV (68.0)
-
このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。
...は CSV ファイルやデータに対する完全なインターフェイスを提供します。
=== 読み込み
//emlist[][ruby]{
require "csv"
csv_text = <<~CSV_TEXT
Ruby,1995
Rust,2010
CSV_TEXT
IO.write "sample.csv", csv_text
# ファイルから一行ずつ
CSV.foreach("sample.csv")......another", "row"]
# ...
end
//}
=== 一行変換
//emlist[][ruby]{
require 'csv'
csv_string = ["CSV", "data"].to_csv # => "CSV,data"
csv_array = "CSV,String".parse_csv # => ["CSV", "String"]
//}
=== ショートカット
//emlist[][ruby]{
require 'csv'
CSV { |csv_out| csv_out......arent, since CSV's defaults should just
magically work for you data. However, you can set these values manually in
the target Encoding to avoid the translation.
It's also important to note that while all of CSV's core parser is now
Encoding agnostic, some features are not. For example, the built-...