[MacRuby-devel] Unclosed quoted field on line 1. (CSV::MalformedCSVError)
Thibault Martin-Lagardette
thibault.ml at gmail.com
Wed Jun 16 12:31:46 PDT 2010
Hi!
The CSV library has been updated in MacRuby trunk (0.7) a few weeks ago, and it now works:
$> macruby t.rb
Name,Price
Gone with the wind,100.12
Who stole my cheese,104.22
Cocoa Programming with Aaron Hillegasse,42.31
--
Thibault Martin-Lagardette
On Jun 13, 2010, at 05:15, Peter Dalmaris wrote:
> Hello,
>
> I am trying to parse a simple CSV file using MacRuby 0.6 on OS X
> 10.6.3, but I am getting this error:
>
> /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/CSV.rb:1817:in
> `block': Unclosed quoted field on line 1. (CSV::MalformedCSVError)
> from /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/CSV.rb:1799:in
> `readline'
> from /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/CSV.rb:1760:in
> `each'
> from /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/CSV.rb:1197:in
> `block'
> from /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/CSV.rb:1326:in
> `open'
> from /Library/Frameworks/MacRuby.framework/Versions/0.6/usr/lib/ruby/1.9.0/CSV.rb:1193:in
> `foreach:'
> from /Users/peterdalmaris/programming/macruby/testing/csvtest.rb:1:in `<main>'
>
> This seems to be relevant to ticket #125, marked as closed
> (http://www.macruby.org/trac/ticket/125). But no matter what I tried
> (methods like CSV.open, CSV.parse), I get the same error message. I
> have tried with several CSV files, making sure there's no problem with
> single or double quotes.
>
> This is my simple code, followed by the CSV test file.
>
> csvtest.rb
> --------------
> require "CSV"
> anArray = CSV.read("books.csv", headers: true)
> #CSV.foreach("books.csv", headers: true) do |row| #Un-comment these
> 3 lines to try the second version
> # puts "#{row["Name"]}, #{row["Price"]}"
> #end
>
> books.csv
> --------------
> Name,Price
> Gone with the wind,100.12
> Who stole my cheese,104.22
> Cocoa Programming with Aaron Hillegasse,42.31
>
> Is this a bug with Macruby 0.6? Or am I doing something wrong? Any
> help greatly appreciated!
>
> Peter
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
More information about the MacRuby-devel
mailing list