るりまサーチ

最速Rubyリファレンスマニュアル検索!
59件ヒット [1-59件を表示] (0.046秒)
トップページ > クエリ:IO[x] > クエリ:encoding[x] > クエリ:generate[x]

別のキーワード

  1. io popen
  2. io pipe
  3. io each_line
  4. io readlines
  5. io each

種類

ライブラリ

クラス

キーワード

検索結果

CSV.generate(str = "", options = Hash.new) {|csv| ... } -> String (18213.0)

このメソッドは与えられた文字列をラップして CSV のオブジェクトとしてブロックに渡します。 ブロック内で CSV オブジェクトに行を追加することができます。 ブロックを評価した結果は文字列を返します。

...

@param str 文字列を指定します。デフォルトは空文字列です。

@param options CSV.new のオプションと同じオプションを指定できます。
:encoding というキーを使用すると出力のエンコーディングを指定することができ...
...][ruby]{
require "csv"

text =<<-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.generate(text, headers: true) do |csv|
csv.add_row(["5", "saburo", "kondo", "34"])
end

print csv
# => id,first name,last name,age
# 1,taro,tanaka,20
# 2...
...場合は csv gem を 1.0.1 以上に更新する必
要があります。

@param options CSV.new のオプションと同じオプションを指定できます。
:encoding というキーを使用すると出力のエンコーディングを指定することができ...

CSV.generate_line(row, options = Hash.new) -> String (6213.0)

このメソッドは一つの Array オブジェクトを CSV 文字列に変換するためのショートカットです。 複数行のCSVを扱う際はCSV#<<を使うとより高速です。

...ディングを推測します。

@param row 文字列の配列を指定します。

@param options CSV.new のオプションと同じオプションを指定できます。
:encoding というキーを使用すると出力のエンコーディングを指定することができ...
...ます。
:row_sep というキーの値には $/ がセットされます。

//emlist[例][ruby]{
require "csv"

taro = ['1', 'taro', 'tanaka', '20']
CSV.generate_line(taro, col_sep: '|') # => "1|taro|tanaka|20\n"
//}

@see CSV.new...

CSV.new(data, options = Hash.new) -> CSV (140.0)

このメソッドは CSV ファイルを読み込んだり、書き出したりするために String か IO のインスタンスをラップします。

...込んだり、書き出したりするために
String か IO のインスタンスをラップします。

ラップされた文字列の先頭から読み込むことになります。
文字列に追記したい場合は CSV.generate を使用してください。
他の位置から処理した...
...した StringIO を渡してください。

@param data String か IO のインスタンスを指定します。
String のインスタンスを指定した場合、CSV#string を使用して
後からデータを取り出すことが出来ます。

@param options CSV を...
...o
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 before par...

CSV (96.0)

このクラスは 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") do |row|
p row
end
# => ["Ruby", "1995"]
# ["Rust", "2...
...e.csv", "wb") do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end

# 文字列へ書き込み
csv_string = CSV.generate do |csv|
csv << ["row", "of", "CSV", "data"]
csv << ["another", "row"]
# ...
end
//}

=== 一行変換

//emlist[][ruby]{
require 'csv'

cs...
...17n 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 written to. Your data is never transcoded
(unless you ask Ruby to transcode it for you) and will literally be parsed in
the Encoding it is in. Thus CSV wi...

NEWS for Ruby 3.0.0 (96.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...ated from positional arguments.
Code that resulted in deprecation warnings in Ruby 2.7 will now
result in ArgumentError or different behavior. 14183
* Procs accepting a single rest argument and keywords are no longer
subject to autosplatting. This now matches the behavior of Procs...
...yword option. 8709
* ENV
* ENV.except has been added, which returns a hash excluding the given keys and their values. 15822
* Windows: Read ENV names and values as UTF-8 encoded Strings 12650
* Encoding
* Added new encoding IBM720. 16233
* Changed default for Encoding.default_...
...nstant references are inlined.
* Always generate appropriate code for `==`, `nil?`, and `!` calls depending on a receiver class.
* Reduce the number of PC accesses on branches and method returns.
* Optimize C method calls a little.
* Compilation process improvements
* It does not k...

絞り込み条件を変える

ruby 1.8.2 feature (30.0)

ruby 1.8.2 feature ruby 1.8.2 での ruby 1.8.1 からの変更点です。

...トフォームの追加

== 1.8.1 (2003-12-25) -> 1.8.2 (2004-12-25)

* cgi/session においてクライアントからセッション ID を指定できてしまうバグが
修正されました。
* cgi/session においてセッション情報を保存するファイル名にセッション...
...ようになりました。((<ruby-dev:24528>))

=== 2004-10-18

: WEBrick::HTTPRequest [lib] [new]
new methods. accept, accept_charset, accept_encoding, accept_language,
content_length and content_type.

: WEBrick::HTTPResponse#content_length= [lib] [new]
: WEBrick::HTTPResponse#content_type=...
...ow [lib] [obsolete]
: CSV::Cell [lib] [obsolete]
CSV::Row と CSV::Cell が deprecated になりました。

: CSV.open, CSV.parse, and CSV,generate
必要ならばユーザが binmode をセットしなければならなくなりました。

: CSV.read [lib] [new]
: CSV.readlines [li...