るりまサーチ

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

別のキーワード

  1. matrix row
  2. csv header_row?
  3. row []=
  4. csv row_sep
  5. matrix row_size

ライブラリ

クラス

モジュール

キーワード

検索結果

<< 1 2 > >>

CSV::FieldInfo#line -> Integer (18113.0)

行番号を返します。

...8-07-09,2018-07-10\n2018-08-09,2018-08-10", headers: true)
csv.convert do |field,field_info|
p field_info.line
Date.parse(field)
end
p csv.to_a

# => 2
# => 2
# => 3
# => 3
# => [#<CSV::Row "date1":#<Date: 2018-07-09 ((2458309j,0s,0n),+0s,2299161j)> "date2":#<Date: 2018-07-10 ((2458310j,0s,0n),+...

CSV.generate_line(row, options = Hash.new) -> String (6226.0)

このメソッドは一つの Array オブジェクトを CSV 文字列に変換するためのショートカットです。 複数行のCSVを扱う際はCSV#<<を使うとより高速です。

...際はCSV#<<を使うとより高速です。

このメソッドは可能であれば row に含まれる最初の nil でない値を用いて出力の
エンコーディングを推測します。

@param row 文字列の配列を指定します。

@param options CSV.new のオプションと同...
...コーディングを指定することができます。
:row_sep というキーの値には $/ がセットされます。

//emlist[例][ruby]{
require "csv"

taro = ['1', 'taro', 'tanaka', '20']
CSV.generate_line(taro, col_sep: '|') # => "1|taro|tanaka|20\n"
//}

@see CSV.new...

CSV#lineno -> Integer (6106.0)

このファイルから読み込んだ最終行の行番号を返します。 フィールドに含まれる改行はこの値には影響しません。

...このファイルから読み込んだ最終行の行番号を返します。
フィールドに含まれる改行はこの値には影響しません。

//emlist[例][ruby]{
require "csv"

csv = CSV.new("header1,header2\nrow1_1,row1_2")
csv.lineno # => 0
csv.readline
csv.lineno # => 1
//}...

CSV#readline -> Array | CSV::Row (3249.0)

String や IO をラップしたデータソースから一行だけ読み込んで フィールドの配列か CSV::Row のインスタンスを返します。

...ドの配列か CSV::Row のインスタンスを返します。

データソースは読み込み用にオープンされている必要があります。

@return ヘッダを使用しない場合は配列を返します。
ヘッダを使用する場合は CSV::Row を返します。

//...
...emlist[例][ruby]{
require "csv"

csv = CSV.new(DATA.read)
csv.readline # => ["header1", "header2"]
csv.readline # => ["row1_1", "row1_2"]

__END__
header1,header2
row
1_1,row1_2
//}...

Readline.set_screen_size(rows, columns) -> Readline (3216.0)

端末のサイズを引数 row、columns に設定します。

...端末のサイズを引数 row、columns に設定します。

@param rows 行数を整数で指定します。

@param columns 列数を整数で指定します。

@raise NotImplementedError サポートしていない環境で発生します。

@see GNU Readline ライブラリの rl_set_scre...

絞り込み条件を変える

CSV#readlines -> [Array] | CSV::Table (3184.0)

残りの行を読み込んで配列の配列を返します。 self の生成時に headers オプションに偽でない値が指定されていた場合は CSV::Table オブジェクトを返します。

...["row1_1", "row1_2"], ["row2_1", "row2_2"]]

__END__
header1,header2
row
1_1,row1_2
row
2_1,row2_2
//}

//emlist[例 headers: true][ruby]{
require "csv"

csv = CSV.new(DATA.read, headers: true)
csv.read
# => #<CSV::Table mode:col_or_row row_count:3>

__END__
header1,header2
row
1_1,row1_2
row
2_1,row2_...

CSV.readlines(path, options = Hash.new) -> [Array] | CSV::Table (3106.0)

CSV ファイルを配列の配列にするために使います。 headers オプションに偽でない値を指定した場合は CSV::Table オブジェクトを返します。

...<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 table.class # => CSV::Table
p table[0] # => #<CSV::Row "id":"1" "first name":"taro" "last name":"tanaka" "age":"20">
//}

@see CSV.new, CSV.table...

CSV.new(data, options = Hash.new) -> CSV (78.0)

このメソッドは CSV ファイルを読み込んだり、書き出したりするために String か IO のインスタンスをラップします。

...の区切り文字列を指定します。この文字列はパースする前にデータの
エンコーディングに変換されます。
: :row_sep
行区切りの文字列を指定します。:auto という特別な値をセットすることができます。
:auto を指定した場...
...", "\r" の並びまでを読みます。
A sequence will be selected even if it occurs in a quoted field, assuming that you
would have the same line endings there. If none of those sequences is
found, +data+ is ARGF, Object::STDIN, Object::STDOUT, or
Object::STDERR, or the stream is only...
...Set manually if speed is important. Also
note that IO objects should be opened in binary mode on Windows if this
feature will be used as the line-ending translation can cause
problems with resetting the document position to where it was before the
read ahead. This String will be transc...

CSV (66.0)

このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。

...ずつ
CSV.foreach("sample.csv") do |row|
p row
end
# => ["Ruby", "1995"]
# ["Rust", "2010"]

# ファイルから一度に
p CSV.read("sample.csv")
# => [["Ruby", "1995"], ["Rust", "2010"]]

# 文字列から一行ずつ
CSV.parse(csv_text) do |row|
p row
end
# => ["Ruby", "1995"]
# ["Rus...
...SV.open("path/to/file.csv", "wb") do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end

# 文字列へ書き込み
csv_string = CSV.generate do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end
//}

=== 一行変換

//emlist[][ruby...
...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 allow you to specify the Encoding.

One minor exception comes when generating CSV into a String with an Encoding
that is not ASCII compatibl...
<< 1 2 > >>