[ruby-list:46553] Re: CSV.openがうまく動きません

From: pegacorn <subscriber.jp@...>
Date: 2009-11-15 10:50:04 UTC
List: ruby-list #46553
2009年11月14日21:42 ichirojiro <ichirojiro@gmail.com>:
> 1.8.7で動いていたプログラムを1.9.1で動かすとCSV.openのところで処理が進ま
> なくなりました。試しに50行ぐらいあるcsvデータを10行程度に減らすと処理は
> 進むようにはなったのですが上記のようなrowデータが1件のみ得られるようにな
> りました。いろいろ試してみてCSV.foreachなら上記のようにうまく動いたので
> CSV.openをすべてCSV.foreachの変えることで一応解決しています。

CSV.open の仕様が変わっているので、それでいいのではないでしょうか。
# リファレンスマニュアルは、まだ対応できていないのだと思います。

csv.rb より
  # :call-seq:
  #   open( filename, mode = "rb", options = Hash.new ) { |faster_csv| ... }
  #   open( filename, options = Hash.new ) { |faster_csv| ... }
  #   open( filename, mode = "rb", options = Hash.new )
  #   open( filename, options = Hash.new )
  #
  # This method opens an IO object, and wraps that with CSV.  This is intended
  # as the primary interface for writing a CSV file.
(中略)
  # This method works like Ruby's open() call, in that it will pass a CSV object
  # to a provided block and close it when the block terminates, or it will
  # return the CSV object when no block is provided.  (*Note*: This is different
  # from the Ruby 1.8 CSV library which passed rows to the block.  Use
  # CSV::foreach() for that behavior.)


-- 
pegacorn

In This Thread

Prev Next