22件ヒット
[1-22件を表示]
(0.504秒)
検索結果
-
CSV
. parse _ line(line , options = Hash . new) -> Array (18325.0) -
このメソッドは一行の CSV 文字列を配列に変換するためのショートカットです。
...ions CSV.new のオプションと同じオプションを指定できます。
//emlist[例][ruby]{
require 'csv'
p CSV.parse_line("1,taro,tanaka,20")
# => ["1", "taro", "tanaka", "20"]
p CSV.parse_line("1|taro|tanaka|20", col_sep: '|')
# => ["1", "taro", "tanaka", "20"]
# 列をダブルクオ......ートで囲むとその中にカンマや改行を含める事もできる。
# 他の仕様も含め詳しくはRFC4180を参照。
p CSV.parse_line("1,\"ta,ro\",\"tana\nka\", 20")
# => ["1", "ta,ro", "tana\nka", " 20"]
//}... -
CSV
. new(data , options = Hash . new) -> CSV (236.0) -
このメソッドは CSV ファイルを読み込んだり、書き出したりするために String か IO のインスタンスをラップします。
...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 available for output, the default
$INPUT_RECORD_SEPARATOR ($/) is us......tant. 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 transcoded into the data's Encoding......配列を返します。
: :headers
:first_row というシンボルか真を指定すると、CSV ファイルの一行目をヘッダとして扱います。
配列を指定するとそれをヘッダとして扱います。文字列を指定すると CSV.parse_line を
使用してパース...