From: Tamara Temple Date: 2013-07-24T06:30:18+09:00 Subject: Re: how to create structure like bellow On Jul 23, 2013, at 2:40 PM, Expert Alart wrote: > Hi... > > I need a structure like bellow "Bellow" is to shout like an elephant. "Below" means comes after. > , i know its not correct syntax, but just > trying to give an idea so that i can get a correct answer .. > > row value : > > a-z15a6=5 > b-z15a6=4 > a-z15a7=3 > b-z15a7=3 > ...... > ....... > a-z16af=3 > > > > > > I need to store Value in this... > z15a={[a-z15a6=>5,b-z15a6=>4],[a-z15a7=>3,b-z15a7=>3],....n} > z16a={[a-z16af=>3,b-z16af=>4],[a-z16ag=>3,b-z16ag=>3],.......n} > > > possible like this > > > [z15a=>{[a-z15a6=>5,b-z15a6=>4],[a-z15a7=>3,b-z15a7=>3],....n}},z16a=>{[a-z16af=>3,b-z16af=>4],[a-z16ag=>3,b-z16ag=>3],.......n}] > > > then i need to calculate value from this example > total of z15a = 5+4+3+3 (top row) > Total of z16a = 3+ 4 +3 +3 (bottom row) > > but dont understand whats the logic will i use ... > > Can any one please give me some light > > Thanks > > -- > Posted via http://www.ruby-forum.com/. > Where is the data coming from? A file? A spreadsheet? A database? This information will aid greatly in giving you a possible answer. What you have above is rather complicated, and it seems you would make your life a lot simpler if you made it less complex. For example, you say your desired outcome is the sum of the values of each hash element in each row. I'm think there must be a much easier way to organize this rather than drilling through the above data structure. Please show where the information comes from; maybe it's simpler than you're thinking.