From: come Date: 2006-12-26T18:15:06+09:00 Subject: Re: Parsing a CSV file having multiple records in RUBYp Hi, The ruby standard library include a CSV parser (you will find the api there : http://www.ruby-doc.org/stdlib/). You should try it. require 'csv' CSV.open(@filepath, "r") do |csv| # csv[0]..csv[n] contains your columns... end Since your file has a header, you could write something like : require 'csv' my_csv = CSV.open(@filepath, "r") header = my_csv.shift # header is a array containing each column of your first line my_csv.each do |row| row.each_index { |i| physician[header[i]] = row[i] } end my_csv.close ... But be carrefull if your file contains more than one line and you didn't overload the "=" operator of physician because you will affect all lines in the same physician object... Krishna Mundra a �crit : > here is my logic..... > rows=Array.new > columns=Array.new > physician= Physician.new // object of physician in to which values are > send after spilltting. > File.open(@filepath, "r") do |f| > f.each_line { |line| > if(count==0) > header=line.to_s > columns=header.split(',') > end > else > str=line.to_s > rows=str.split(',') > columns.each do |col| > physician[columns[cnt]]= rows[cnt] > cnt=cnt+1 > end > end