別のキーワード
種類
- インスタンスメソッド (77)
- 特異メソッド (22)
- モジュール関数 (11)
- クラス (11)
- 文書 (6)
クラス
- CSV (44)
- IO (44)
-
Zlib
:: GzipReader (11)
モジュール
- Kernel (11)
キーワード
- CSV (11)
-
NEWS for Ruby 2
. 6 . 0 (6) -
close
_ read (11) - gets (11)
- read (22)
検索結果
先頭5件
-
IO
# readlines(limit , chomp: false) -> [String] (18293.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\......chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs = $ / , chomp: false) -> [String] (18293.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\......chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(rs , limit , chomp: false) -> [String] (18293.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\......chomp = true)][ruby]{
IO.write("testfile", "line1,\rline2,\r\nline3,\n")
File.open("testfile") { |f| p f.readlines(chomp: true) } # => ["line1,\rline2,", "line3,"]
File.open("testfile") { |f| p f.readlines("\r", chomp: true) } # => ["line1,", "line2,", "\nline3,\n"]
//}
@see $/, IO#gets... -
IO
# readlines(limit) -> [String] (18257.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\... -
IO
# readlines(rs = $ / ) -> [String] (18257.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\... -
IO
# readlines(rs , limit) -> [String] (18257.0) -
データを全て読み込んで、その各行を要素としてもつ配列を返します。 既に EOF に達していれば空配列 [] を返します。
...2,\nline3,\n")
File.open("testfile") { |f| p f.readlines } # => ["line1,\n", "line2,\n", "line3,\n"]
File.open("testfile") { |f| p f.readlines(3) } # => ["lin", "e1,", "\n", "lin", "e2,", "\n", "lin", "e3,", "\n"]
File.open("testfile") { |f| p f.readlines(",") } # => ["line1,", "\nline2,", "\... -
Zlib
:: GzipReader # readlines(rs = $ / ) -> Array (18253.0) -
IO クラスの同名メソッドIO#readlinesと同じです。
...IO クラスの同名メソッドIO#readlinesと同じです。
但し、gzip ファイル中に
エラーがあった場合 Zlib::Error 例外や
Zlib::GzipFile::Error 例外が発生します。
gzip ファイルのフッターの処理に注意して下さい。
gzip ファイルのフッター......rを参照
require 'zlib'
=begin
# hoge.gz がない場合は下記で作成できる。
Zlib::GzipWriter.open('hoge.gz') { |gz|
gz.puts 'hoge'
gz.puts 'fuga'
}
=end
Zlib::GzipReader.open('hoge.gz') { |gz|
p gz.readlines #=> ["hoge\n", "fuga\n"]
}
@see IO#readlines... -
CSV
# readlines -> [Array] | CSV :: Table (15303.0) -
残りの行を読み込んで配列の配列を返します。 self の生成時に headers オプションに偽でない値が指定されていた場合は CSV::Table オブジェクトを返します。
残りの行を読み込んで配列の配列を返します。
self の生成時に headers オプションに偽でない値が指定されていた場合は CSV::Table オブジェクトを返します。
データソースは読み込み用にオープンされている必要があります。
//emlist[例 headers: false][ruby]{
require "csv"
csv = CSV.new(DATA.read)
csv.read
# => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
__END__
header1,head... -
CSV
. readlines(path , options = Hash . new) -> [Array] | CSV :: Table (15303.0) -
CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
CSV ファイルを配列の配列にするために使います。
headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
@param path CSV ファイルのパスを指定します。
@param options CSV.new のオプションと同じオプションを指定できます。
:encoding というキーを使用すると入力のエンコーディングを指定することができます。
入力のエンコーディングか Encoding.default_external と異なる場合は
必ず指定... -
Kernel
. # gets(rs = $ / ) -> String | nil (207.0) -
ARGFから一行読み込んで、それを返します。 行の区切りは引数 rs で指定した文字列になります。
...mmon
//}
//emlist[c.txt][ruby]{
ARGF
# スクリプトに指定した引数 (Object::ARGV を参照) をファイル名と
# みなして、それらのファイルを連結した 1 つの仮想ファイルを表すオブジェクトです。
//}
@see $/,ARGF,Kernel.#readlines,Kernel.#readline... -
CSV
# read -> [Array] | CSV :: Table (203.0) -
残りの行を読み込んで配列の配列を返します。 self の生成時に headers オプションに偽でない値が指定されていた場合は CSV::Table オブジェクトを返します。
残りの行を読み込んで配列の配列を返します。
self の生成時に headers オプションに偽でない値が指定されていた場合は CSV::Table オブジェクトを返します。
データソースは読み込み用にオープンされている必要があります。
//emlist[例 headers: false][ruby]{
require "csv"
csv = CSV.new(DATA.read)
csv.read
# => [["header1", "header2"], ["row1_1", "row1_2"], ["row2_1", "row2_2"]]
__END__
header1,head... -
CSV
. read(path , options = Hash . new) -> [Array] | CSV :: Table (203.0) -
CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
CSV ファイルを配列の配列にするために使います。
headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。
@param path CSV ファイルのパスを指定します。
@param options CSV.new のオプションと同じオプションを指定できます。
:encoding というキーを使用すると入力のエンコーディングを指定することができます。
入力のエンコーディングか Encoding.default_external と異なる場合は
必ず指定... -
IO
# close _ read -> nil (118.0) -
読み込み用の IO を close します。主にパイプや読み書き両用に作成し た IO オブジェクトで使用します。
...オープンされていなければ発生します。
@raise Errno::EXXX close に失敗した場合に発生します。
//emlist[例][ruby]{
IO.popen("/bin/sh","r+") do |f|
f.close_read
# f.readlines # => IOError: not opened for reading
end
//}
@see IO#close, IO#closed?, IO#close_write...