るりまサーチ

最速Rubyリファレンスマニュアル検索!
55件ヒット [1-55件を表示] (0.045秒)
トップページ > クエリ:new[x] > クエリ:shift[x] > クラス:CSV[x]

別のキーワード

  1. openssl new
  2. _builtin new
  3. rexml/document new
  4. resolv new
  5. socket new

ライブラリ

キーワード

検索結果

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

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

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

ラップされた文字列の先頭から読み込むことになります。
文字列に追記したい場合は CSV.generate を使用し...
...指定すると CSV.parse_line を
使用してパースした結果をヘッダとして扱います。このとき、:col_sep, :row_sep, :quote_char
はこのインスタンスと同じものを使用します。この設定は CSV#shift
の返り値を配列のかわりに CSV::Row のイ...
...][ruby]{
require "csv"

users =<<-EOS
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
EOS

File.write("test.csv", users)

File.open("test.csv", "r") do |f|
csv
= CSV.new(f, headers: true)
csv
.class # => CSV
csv
.first # => #<CSV::Row "id":"1" "first...

CSV#shift -> Array | CSV::Row (15108.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
row1_1,row1_2
//}...

CSV#return_headers? -> bool (31.0)

ヘッダを返す場合は、真を返します。 そうでない場合は、偽を返します。

...]{
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
.return_hea...
...ders? # => true
csv
.shift # => #<CSV::Row "header1":"header1" "header2":"header2">
//}

@see CSV.new...

CSV#gets -> Array | CSV::Row (8.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
row1_1,row1_2
//}...

CSV#readline -> Array | CSV::Row (8.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
row1_1,row1_2
//}...

絞り込み条件を変える