22件ヒット
[1-22件を表示]
(0.035秒)
検索結果
-
String
# parse _ csv(**options) -> [String] (39238.0) -
CSV.parse_line(self, options) と同様です。
....parse_csv # => ["Matz", "Ruby"]
p "Matz|Ruby\r\n".parse_csv(col_sep: '|', row_sep: "\r\n") # => ["Matz", "Ruby"]
//}
Ruby 2.6 (CSV 3.0.2) から、次のオプションが使えるようになりました。
//emlist[][ruby]{
require 'csv'
p "1,,3\n".parse_csv......# => ["1", nil, "3"]
p "1,,3\n".parse_csv(nil_value: Float::NAN) # => ["1", NaN, "3"]
//}
@see CSV.new, CSV.parse_line......"1,,3\n".parse_csv(nil_value: Float::NAN) # => ["1", NaN, "3"]
//}
Ruby 2.7 (CSV 3.1.2) から、次のオプションが使えるようになりました。
//emlist[][ruby]{
require 'csv'
p "Matz, Ruby\n".parse_csv # => ["Matz", " Ruby"]
p "Matz, Ruby\n".parse_csv(strip: tr... -
CSV (54.0)
-
このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。
...込み
csv_string = CSV.generate do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end
//}
=== 一行変換
//emlist[][ruby]{
require 'csv'
csv_string = ["CSV", "data"].to_csv # => "CSV,data"
csv_array = "CSV,String".parse_csv # => ["CSV", "String"]
//}
===......%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 object being read from or......scoded
(unless you ask Ruby to transcode it for you) and will literally be parsed in
the Encoding it is in. Thus CSV will return Arrays or Rows of Strings in the
Encoding of your data. This is accomplished by transcoding the parser itself
into your Encoding.
Some transcoding must take place, of c...