From: Stuart Clarke Date: 2009-02-03T07:37:36+09:00 Subject: Re: Hash counting Thanks Robert. This is more to what I need. However I am still getting no result, everything works until we get to this section: > counts = Hash.new(0) > eventdateID.each {|d| counts[d] +=1} > counts.each do |d,cnt| > @alerts.push("#{event.event_id} #{@tab} #{event.time_written} > #{@tab}#{event.event_type} #{@tab} #{type}") if cnt >= 5 > end Does it make any difference that the data being read into the eventdateID is alphanumeric eg: MonFeb022009 MonFeb022009 MonFeb022009 Many thanks. Robert Klemme wrote: > On 02.02.2009 21:43, Stuart Clarke wrote: >> end > You probably rather want > > eventdateID.push eventsbydate.gsub(/\s/, '')[0..7] + > eventsbydate[26..30] > counts = Hash.new(0) > eventdateID.each {|d| counts[d] +=1} > counts.each do |d,cnt| > @alerts.push("#{event.event_id} #{@tab} #{event.time_written} > #{@tab}#{event.event_type} #{@tab} #{type}") if cnt >= 5 > end > > Cheers > > robert -- Posted via http://www.ruby-forum.com/.