Forum: Ruby CSV:mode must be 'r', 'rb', 'w', or 'wb'

Posted by Prog Rammer (proggrammer)
on 2012-11-22 13:07
Why this code is giving error:

code is:
CSV.open(filename, 'a') do |csv|
    csv<<[a,b,c,d]
end

Error is:

mode must be 'r', 'rb', 'w', or 'wb'

Note: I want to append.
Posted by unknown (Guest)
on 2012-11-22 20:03
(Received via mailing list)
Am 22.11.2012 13:07, schrieb ajay paswan:
>
> Note: I want to append.

A quick search for the error message shows that
this is a Ruby 1.8 issue...

With Ruby 1.9.3-p194 it works perfectly.
Posted by Prog Rammer (proggrammer)
on 2012-11-23 09:00
unknown wrote in post #1085940:
> Am 22.11.2012 13:07, schrieb ajay paswan:
>>
>> Note: I want to append.
>
> A quick search for the error message shows that
> this is a Ruby 1.8 issue...
>
> With Ruby 1.9.3-p194 it works perfectly.

but am using ruby 1.9.3p327.
Posted by Brian Candler (candlerb)
on 2012-11-23 22:07
ajay paswan wrote in post #1085970:
> unknown wrote in post #1085940:
>> Am 22.11.2012 13:07, schrieb ajay paswan:
>>>
>>> Note: I want to append.
>>
>> A quick search for the error message shows that
>> this is a Ruby 1.8 issue...
>>
>> With Ruby 1.9.3-p194 it works perfectly.
>
> but am using ruby 1.9.3p327.

Sure you don't have two versions installed at once? Try adding to the 
top of your script:

puts RUBY_DESCRIPTION
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.