44件ヒット
[1-44件を表示]
(0.025秒)
検索結果
先頭4件
-
CSV
. readlines(path , options = Hash . new) -> [Array] | CSV :: Table (15125.0) -
CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
...同じオプションを指定できます。
:encoding というキーを使用すると入力のエンコーディングを指定することができます。
入力のエンコーディングか Encoding.default_external と異なる場合は
必ず......指定しなければなりません。
//emlist[例][ruby]{
require "csv"
require "pp"
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
pp CSV.read("test.csv")
# => [["id", "first name", "last name", "age"],
# ["1"......"suzuki", "18"],
# ["3", "ami", "sato", "19"],
# ["4", "yumi", "adachi", "21"]]
//}
//emlist[例][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
table = CSV.read("test.csv", headers: true)
p... -
CSV (108.0)
-
このクラスは 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") do |row|
p r......{ |csv_str| csv_str << %w{my data here} } # to a String
CSV($stderr) { |csv_err| csv_err << %w{my data here} } # to $stderr
//}
=== CSV と文字エンコーディング (M17n or Multilingualization)
This new CSV parser is m17n savvy. The parser works in the Encoding of the IO
or String o......ll of Ruby's Encodings.
Anyway, the practical side of this is simple: make sure IO and String objects
passed into CSV have the proper Encoding set and everything should just work.
CSV methods that allow you to open IO objects (CSV::foreach(), CSV::open(),
CSV::read(), and CSV::readlines()) do allo... -
CSV
. read(path , options = Hash . new) -> [Array] | CSV :: Table (25.0) -
CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
...同じオプションを指定できます。
:encoding というキーを使用すると入力のエンコーディングを指定することができます。
入力のエンコーディングか Encoding.default_external と異なる場合は
必ず......指定しなければなりません。
//emlist[例][ruby]{
require "csv"
require "pp"
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
pp CSV.read("test.csv")
# => [["id", "first name", "last name", "age"],
# ["1"......"suzuki", "18"],
# ["3", "ami", "sato", "19"],
# ["4", "yumi", "adachi", "21"]]
//}
//emlist[例][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
table = CSV.read("test.csv", headers: true)
p... -
ruby 1
. 8 . 2 feature (24.0) -
ruby 1.8.2 feature ruby 1.8.2 での ruby 1.8.1 からの変更点です。
...ようになりました。((<ruby-dev:24528>))
=== 2004-10-18
: WEBrick::HTTPRequest [lib] [new]
new methods. accept, accept_charset, accept_encoding, accept_language,
content_length and content_type.
: WEBrick::HTTPResponse#content_length= [lib] [new]
: WEBrick::HTTPResponse#content_type=......いるバグを修正しました。((<ruby-dev:23690>))
$ ruby1.8.1 -e 'class X;end; x=X.new; class << x;p self < X; end'
true
$ ruby1.8.2 -e 'class X;end; x=X.new; class << x;p self < X; end'
nil
=== 2004-06-04
: IO#gets, $_ [ruby] [change]
gets の返り値が nil で......CSV,generate
必要ならばユーザが binmode をセットしなければならなくなりました。
: CSV.read [lib] [new]
: CSV.readlines [lib] [new]
追加。
: Marshal.dump [ruby] [bug]
特異メソッドを定義されていないオブジェクトを dump できない場...