11件ヒット
[1-11件を表示]
(0.044秒)
検索結果
先頭1件
-
CSV (56.0)
-
このクラスは CSV ファイルやデータに対する完全なインターフェイスを提供します。
...は CSV ファイルやデータに対する完全なインターフェイスを提供します。
=== 読み込み
//emlist[][ruby]{
require "csv"
csv_text = <<~CSV_TEXT
Ruby,1995
Rust,2010
CSV_TEXT
IO.write "sample.csv", csv_text
# ファイルから一行ずつ
CSV.foreach("sample.csv")......(csv_text)
# => [["Ruby", "1995"], ["Rust", "2010"]]
//}
=== 書き込み
//emlist[][ruby]{
require 'csv'
# ファイルへ書き込み
CSV.open("path/to/file.csv", "wb") do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end
# 文字列へ書き込み
csv_string......scoded to match your data. Hopefully this
makes the entire process feel transparent, since CSV's defaults should just
magically work for you data. However, you can set these values manually in
the target Encoding to avoid the translation.
It's also important to note that while all of CSV's core p...