Syntax error from CSV operation - need help

Hi,

Need help! Keep getting an error as I am trying to run the code :

hash = { 'A' => [ 'v', 'x', 'y' , 'z' ] , 'B' => [ 'm', 'n' , 'o' ] } #
!> assigned but unused variable - hash
CSV.open ('/home/kirti/workspace/Ruby/a.csv',"w", :headers => true)

csv> # !> possibly useless use of a literal in void context

   hash.each do |k, v|
      csv[k]=v
   end
end
# ~> -:2: syntax error, unexpected ',', expecting ')'
# ~> ...me/kirti/workspace/Ruby/a.csv',"w", :headers => true) |csv|
# ~> ... ^
# ~> -:2: syntax error, unexpected ',', expecting end-of-input
# ~> ...irti/workspace/Ruby/a.csv',"w", :headers => true) |csv|
# ~> ... ^

Could anyone help me, where I did such mistake?

···

--
Posted via http://www.ruby-forum.com/\.

Hi,

Need help! Keep getting an error as I am trying to run the code :

hash = { 'A' => [ 'v', 'x', 'y' , 'z' ] , 'B' => [ 'm', 'n' , 'o' ] } #
!> assigned but unused variable - hash
CSV.open ('/home/kirti/workspace/Ruby/a.csv',"w", :headers => true)

missing "do" here?

···

On Sun, Jan 26, 2014 at 11:11 AM, Arup Rakshit <lists@ruby-forum.com> wrote:

>csv> # !> possibly useless use of a literal in void context
   hash.each do |k, v|
      csv[k]=v
   end
end
# ~> -:2: syntax error, unexpected ',', expecting ')'
# ~> ...me/kirti/workspace/Ruby/a.csv',"w", :headers => true) |csv|
# ~> ... ^
# ~> -:2: syntax error, unexpected ',', expecting end-of-input
# ~> ...irti/workspace/Ruby/a.csv',"w", :headers => true) |csv|
# ~> ... ^

Could anyone help me, where I did such mistake?

--
Posted via http://www.ruby-forum.com/\.