From: Robert Klemme Date: 2011-10-07T20:30:47+09:00 Subject: Re: Read thru Csv file and store it in variables On Thu, Oct 6, 2011 at 1:24 AM, ideal one wrote: >     Thanks for your Info, Sorry if i am not clear with my requirement. > Let me clearly explain below: I am looking for DATA DRIVEN Scenario. > > I read CSV file and use that data in my code. ie If i have 10 rows, i > will run my program 10 times. > i will have to iterate each time into my code and use different row > values, its sort of Data Driven Automation. > let me know if my requirement makes sense. You can directly assign fields to block parameters and have your code inside the foreach loop: 13:27:13 Temp$ ./csv.rb data.csv name=James country=USA name=Robert country=Germany name=Michael country=Neverland 13:27:18 Temp$ cat data.csv James,bar,USA Robert,bbb,Germany Michael,ignore,Neverland 13:27:27 Temp$ cat -n csv.rb 1 #!/bin/env ruby19 2 3 require 'csv' 4 5 CSV.foreach ARGV.shift do |name, ign1, country| 6 printf "name=%-30s country=%-30s\n", name, country 7 end 13:28:18 Temp$ Of course you can invoke any method from there as well. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/