From: ideal one Date: 2011-10-06T06:14:10+09:00 Subject: Re: Read thru Csv file and store it in variables "Jesús Gabriel y Galán" wrote in post #1025175: > On Wed, Oct 5, 2011 at 7:25 PM, ideal one wrote: >> >> Files/Ruby/lib/ruby/gems/1.9.1/gems/fastercsv-1.5.4/lib/faster_csv.rb:13:in >> `const_missing': Please switch to Ruby 1.9's standard CSV library. It's >> FasterCSV plus support for Ruby 1.9's m17n encoding engine. >> (NotImplementedError) >> >> >> I am not aware of this error, Can any of you plz recommend better way to >> achieve the result. > > In Ruby 1.9, fasterCSV has been made the implementation of the stdlib > CSV, so you should be able to remove the rubygems (which btw, is also > included by default in 1.9) and just make require 'csv' and CSV > instead of FasterCSV. > > http://ruby-doc.org/stdlib/libdoc/csv/rdoc/index.html > > Jesus. Hi there, I did implement the csv using hash, but Is there a way i can get data for each iteration from Hash. My Input --------- Name,Account,T1,T2,Date test1,1,QA1,PQ1,10-Sep test2,2,QA2,PQ2,11-Sep test3,3,QA3,PQ3,12-Sep eg: In my Iteration, I want to utilize each 1st row: Run Program Name=test1 Account=1 T1=QA1 end row2 values Run Program Name=test2 Account=2 T1=QA2 end so on, till the end of the file. require 'csv' path = "C:/Users/test/Desktop/data.txt" csv_data = CSV.read(path) headers = csv_data.shift.map {|i| i.to_s } data1 = csv_data.map {|row| row.map {|cell| cell.to_s } } hashe1 = string_data.map {|row| Hash[*headers.zip(row).flatten] } puts "Done" -- Posted via http://www.ruby-forum.com/.