1408件ヒット
[1-100件を表示]
(0.019秒)
クラス
- Array (11)
- CSV (704)
-
CSV
:: FieldInfo (66) -
CSV
:: Row (297) -
CSV
:: Table (319) - String (11)
キーワード
- << (33)
- == (22)
- [] (44)
- []= (33)
-
add
_ row (11) - binmode (11)
- binmode? (11)
-
by
_ col (11) -
by
_ col! (11) -
by
_ col _ or _ row (11) -
by
_ col _ or _ row! (11) -
by
_ row (11) -
by
_ row! (11) - close (11)
-
close
_ read (11) -
close
_ write (11) - closed? (11)
-
col
_ sep (11) - convert (33)
- converters (11)
- delete (22)
-
delete
_ if (33) - each (44)
- empty? (22)
- encoding (11)
- eof (11)
- eof? (11)
-
external
_ encoding (11) - fcntl (11)
- field (11)
- field? (11)
-
field
_ row? (11) -
field
_ size _ limit (11) - fields (11)
- fileno (11)
- flock (11)
- flush (11)
-
force
_ quotes? (11) - fsync (11)
- gets (11)
- header (11)
- header= (11)
- header? (11)
-
header
_ convert (33) -
header
_ converters (11) -
header
_ row? (22) - headers (33)
- include? (11)
- index (22)
- index= (11)
- inspect (33)
-
internal
_ encoding (11) - ioctl (11)
- isatty (11)
- length (22)
- line (11)
- line= (11)
- lineno (11)
- mode (11)
-
parse
_ csv (11) - path (11)
- pid (11)
- pos (11)
- pos= (11)
- push (22)
- puts (11)
-
quote
_ char (11) - read (11)
- readline (11)
- readlines (11)
- reopen (11)
-
return
_ headers? (11) - rewind (11)
- row (11)
-
row
_ sep (11) - seek (11)
- shift (11)
- size (22)
-
skip
_ blanks? (11) - stat (11)
- string (11)
- sync (11)
- sync= (11)
- table (11)
- tell (11)
-
to
_ a (11) -
to
_ csv (33) -
to
_ hash (11) -
to
_ i (11) -
to
_ io (11) -
to
_ s (22) - truncate (11)
- tty? (11)
-
unconverted
_ fields? (11) -
values
_ at (22) -
write
_ headers? (11)
検索結果
先頭5件
-
Array
# to _ csv(**options) -> String (3.0) -
CSV.generate_line(self, options) と同様です。
...
CSV.generate_line(self, options) と同様です。
Array オブジェクトを 1 行の CSV 文字列に変換するためのショートカットです。
@param options CSV.generate_line と同様のオプションを指定します。
//emlist[][ruby]{
require 'csv'
p [1, 'Matz', :Ruby, Dat......e.new(1965, 4, 14)].to_csv # => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}
@see CSV.generate_line......e.new(1965, 4, 14)].to_csv # => "1,Matz,Ruby,1965-04-14\n"
p [1, 'Matz', :Ruby, Date.new(1965, 4, 14)].to_csv(col_sep: ' ', row_sep: "\r\n") # => "1 Matz Ruby 1965-04-14\r\n"
//}
Ruby 3.0 (CSV 3.1.9) から、次のオプションが使えるようになりました....../emlist[][ruby]{
require 'csv'
puts [1, nil].to_csv # => 1,
puts [1, nil].to_csv(write_nil_value: "N/A") # => 1,N/A
puts [2, ""].to_csv # => 2,""
puts [2, ""].to_csv(write_empty_value: "BLANK") # => 2,BLANK
//}
@see CSV.generate_line... -
CSV
# <<(row) -> self (3.0) -
自身に row を追加します。
...m row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値
のみが追加されます。
//emlist[例 配列を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name......i,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
csv.puts(["5", "saburo", "kondo", "34"])
end
print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}
//emlist[例 CSV::Row を......ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
en... -
CSV
# add _ row(row) -> self (3.0) -
自身に row を追加します。
...m row 配列か CSV::Row のインスタンスを指定します。
CSV::Row のインスタンスが指定された場合は、CSV::Row#fields の値
のみが追加されます。
//emlist[例 配列を指定][ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name......i,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
csv.puts(["5", "saburo", "kondo", "34"])
end
print File.read("test.csv")
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2,jiro,suzuki,18
# 3,ami,sato,19
# 4,yumi,adachi,21
# 5,saburo,kondo,34
//}
//emlist[例 CSV::Row を......ruby]{
require "csv"
File.write("test.csv", <<CSV)
id,first name,last name,age
1,taro,tanaka,20
2,jiro,suzuki,18
3,ami,sato,19
4,yumi,adachi,21
CSV
CSV.open("test.csv", "a") do |csv|
row = CSV::Row.new(["id", "first name", "last name", "age"], ["5", "saburo", "kondo", "34"])
csv.add_row(row)
en... -
CSV
# binmode -> self (3.0) -
IO#binmode に委譲します。
IO#binmode に委譲します。
@see IO#binmode -
CSV
# binmode? -> bool (3.0) -
IO#binmode? に委譲します。
IO#binmode? に委譲します。
@see IO#binmode? -
CSV
# close -> nil (3.0) -
IO#close に委譲します。
IO#close に委譲します。
@see IO#close -
CSV
# close _ read -> nil (3.0) -
IO#close_read に委譲します。
IO#close_read に委譲します。
@see IO#close_read -
CSV
# close _ write -> nil (3.0) -
IO#close_write に委譲します。
IO#close_write に委譲します。
@see IO#close_write -
CSV
# closed? -> bool (3.0) -
IO#closed? に委譲します。
IO#closed? に委譲します。
@see IO#closed? -
CSV
# col _ sep -> String (3.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...