i have a person details csv file. I am trying to write a code to search
for a particular person based on his first and last name. I wrote the
code to search for single value but i am not sure how to search through
a table with multiple keys. My code is:
def load_xvid_file("person.csv", "r") do |csv|)
@firstnames = []
@lastnames = []
csv_file = CSV.read(person.csv)
csv_contents.shift
csv_contents.each do |row|
@firstnames << row[0]
end
csv_contents.each do |row|
@lastnames << row[1]
end
@firstnames.each { |f| f.downcase! }
@lastnames.each { |l| l.downcase! }
end
def search_for_person(fname,lname)
fname = fname.downcase
lname = lname.downcase
puts
if @firstnames.include?(fname)
if @lastnames.include?(lname)
puts "#{fname} #{lname} found!"
else
puts "#{fname} #{lname} not found!"
end
prompt
end
this code doesn't work. can you help me debug this.
Thank you loads in advance.
Regards,
Akshath
--
Posted via http://www.ruby-forum.com/.