From: Stuart Clarke Date: 2009-02-04T01:15:17+09:00 Subject: Re: Hash counting Thanks for replying and sorry for the confusion. My hash (counts) contains date and time ID's like so TueAug052008 When I do a puts on counts I get a list of these as per there date and time values which is what I want. However counting to see if there is more than 5 occurances of one the ID values fails and doesn't find anything in my data set. I have done as you asked and the output is as follows: {"WedAug062008"=>1} This suggests there is a problem. Just for your information doing an output on counts (the hash) gives this: MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 WedAug062008 WedAug062008 Thanks for your help Robert Klemme wrote: > 2009/2/3 Stuart Clarke : >> I have worked out the problem but I am a little unsure how to solve it. >> >> We have counts which holds all of the event ID's, however |d, cnt| is >> not counting the number of matching ID numbers and it just assigns each >> ID the number 1. > > What does that mean? What's in the Hash? > >> TueAug052008 >> 1 >> 1 >> 1 >> 1 >> 1 >> >> Can anyone help me with a fix? Many thanks > > Frankly, you lost me there. Please do this: > > require 'pp' > > File.open('/tmp/log', 'w') {|io| io.write(counts.pretty_inspect)} > > And look at the output and / or post it here. > > robert -- Posted via http://www.ruby-forum.com/.