[#38392] Enumerable#gather_each — Tanaka Akira <akr@...>

ときに、複数行をまとめて扱いたいことがあります。

47 messages 2009/05/09
[#38394] Re: Enumerable#gather_each — ujihisa <ujihisa@...> 2009/05/09

ujihisaと申します。

[#38400] Re: Enumerable#gather_each — Yukihiro Matsumoto <matz@...> 2009/05/09

まつもと ゆきひろです

[#38399] Re: Enumerable#gather_each — "Akinori MUSHA" <knu@...> 2009/05/09

At Sat, 9 May 2009 15:30:20 +0900,

[#38405] Re: Enumerable#gather_each — Tanaka Akira <akr@...> 2009/05/10

In article <86r5yy2nrg.knu@iDaemons.org>,

[#38417] Re: Enumerable#gather_each — "Akinori MUSHA" <knu@...> 2009/05/10

At Sun, 10 May 2009 10:08:47 +0900,

[#38524] [Bug #1503] -Kuをつけた時、/[#{s}]/n と Regexp.new("[#{s}]",nil,"n") で実行結果が異なる — sinnichi eguchi <redmine@...>

Bug #1503: -Kuをつけた時、/[#{s}]/n と Regexp.new("[#{s}]",nil,"n") で実行結果が異なる

8 messages 2009/05/22

[ruby-dev:38531] [Bug #1075](Rejected) \r\n と \n が混在した CSV がエラーになる

From: James Gray <redmine@...>
Date: 2009-05-22 15:59:28 UTC
List: ruby-dev #38531
チケット #1075 が更新されました。 (by James Gray)

ステータス OpenからRejectedに変更

Ruby 1.9 uses an all new CSV library.  It's somewhat more strict in it's parsing as a means to get dramatically more speed.

Here it is correctly reporting that \r is an illegal character in an unquoted field.  That rule comes from the CSV RFC.

The reason it isn't treated as a line ending is that the new library tried to guess your line ending by default.  When doing so, the first thing it saw was the bare \n in the second quoted field.  Thus it assumed the line ending was a \n.  However, it looks like the real line ending here is \r\n.

You can easily fix this by just explicitly setting the line ending, so CSV won't guess it, wrongly in this case:

$ ruby_dev -v -rcsv -e 'p CSV.parse("a,\"b\n\",c\r\n", row_sep: "\r\n")'
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-darwin9.6.0]
[["a", "b\n", "c"]]

Hope that helps.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/1075

----------------------------------------
http://redmine.ruby-lang.org

In This Thread

Prev Next