312件ヒット
[1-100件を表示]
(0.048秒)
別のキーワード
クラス
- Array (12)
- CSV (180)
-
CSV
:: Row (24) -
CSV
:: Table (84) - String (12)
検索結果
先頭5件
-
String
# parse _ csv(**options) -> [String] (6151.0) -
CSV.parse_line(self, options) と同様です。
...
CSV.parse_line(self, options) と同様です。
1 行の CSV 文字列を、文字列の配列に変換するためのショートカットです。
@param options CSV.new と同様のオプションを指定します。
//emlist[][ruby]{
require "csv"
p "Matz,Ruby\n".parse_csv......]
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......"]
//}
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: true) # => ["Matz", "Ruby"]
//}
@see CSV.new, CSV.parse_line... -
CSV
:: Table # empty? -> bool (6121.0) -
ヘッダーを除いて、データがないときに true を返します。
...ーを除いて、データがないときに true を返します。
Array#empty? に委譲しています。
//emlist[][ruby]{
require 'csv'
csv = CSV.new("a,b\n", headers: true)
table = csv.read
p table.empty? # => true
table << [1, 2]
p table.empty? # => false
//}
@see Array#empty?... -
CSV
:: Table # push(*rows) -> self (6121.0) -
複数の行を追加するためのショートカットです。
...row }
//}
@param rows CSV::Row のインスタンスか配列を指定します。
//emlist[例][ruby]{
require 'csv'
csv = CSV.new("a,b,c\n1,2,3", headers: true)
table = csv.read
rows = [
CSV::Row.new(table.headers, [4, 5, 6]),
[7, 8, 9]
]
table.push(*rows)
p table[0..2]
# => [#<CSV::Row "a"......:"1" "b":"2" "c":"3">, #<CSV::Row "a":4 "b":5 "c":6>, #<CSV::Row "a":7 "b":8 "c":9>]
//}
@see CSV::Table#<<... -
CSV
:: Row # empty? -> bool (6119.0) -
内部で保持している @row へ委譲します。
...内部で保持している @row へ委譲します。... -
CSV
# col _ sep -> String (6109.0) -
カラム区切り文字列として使用する文字列を返します。
..."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
csv = CSV.new(users, headers: true, col_sep: "|")
csv.col_sep # => "|"
csv.first.to_a # => [["id", "1"], ["first name", "taro"], ["last name", "tanaka"], ["age", "20"]]
csv = CSV.......new(users, headers: true)
csv.col_sep # => ","
csv.first.to_a # => [["id|first name|last name|age", "1|taro|tanaka|20"]]
//}
@see CSV.new... -
CSV
# path -> String (6109.0) -
IO#path に委譲します。
...IO#path に委譲します。
@see IO#path... -
CSV
# pid -> Integer | nil (6109.0) -
IO#pid に委譲します。
...IO#pid に委譲します。
@see IO#pid... -
CSV
# pos -> Integer (6109.0) -
IO#pos, IO#tell に委譲します。
...IO#pos, IO#tell に委譲します。
@see IO#pos, IO#tell... -
CSV
# pos=(n) (6109.0) -
IO#pos= に委譲します。
...IO#pos= に委譲します。
@see IO#pos=...