require 'csv' people = CSV.read('text.txt') young_people = people.find_all do |p| p[3].to_i.between?(20, 40) end puts young_people.inspect //File: text.txt F,M,M,45 L,C,F,23 D,P,F,38