From: Krishna Mundra Date: 2006-12-26T16:35:44+09:00 Subject: Parsing a CSV file having multiple records in RUBYp Hi everyone, Can anyone help me in parsing a CSV file,with comma seperated multiple records (multiple columns and multiple rows).... What i am doing is uploading a CSV file and reading the records from CSV file,first row contains field names(database field names),reaing record line by line and splitting each record by a comma(since CSV file is a comma seperated fields) and sending the splitted data into corresponding fields of database. everything goes well except last column of the record is skipping in my logic. My logic unable to read the last field values and field name.If I put an extra column name,my logic is working well and good. 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 Can anyone solve my problem,Its urgent -- Posted via http://www.ruby-forum.com/.