I’m currently porting a script to 1.9 and I’m having problems getting
CSV parsing to work. This script worked fine in 1.8.7 and used the
FasterCSV library for parsing. After playing around in the IRB, I have
determined that the current parser seems incapable of handling newlines
as row seperators (a rather basic and important feature).
I tested with a simple file whose contents are:
This file was created using a basic text editor and does not contain any
unorthodox newline characters. Attempting to parse this file results in
the following error:
block (2 levels) in shift': Unquoted fields do not allow \r or \n (line 1). (CSV::MalformedCSVError) from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1856:ineach’
block in shift' from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1818:inloop’
shift' from C:/Ruby192/lib/ruby/1.9.1/csv.rb:1760:ineach’
The return value of the opened csv file shows row_sep to be “\r\n” which
seems correct. I have tried manually setting the value of row_sep when
calling CSV::open but I get the same issue.
Once again, I do not have this problem with FasterCSV under 1.8.7 (which
as I understand, is the same code used in 1.9’s csv library). I’m using
Ruby 1.9.2p0 on Windows XP. I would greatly appreciate any help.