1
我結束了10個CSV :: Row對象的數組。現在我想配對它們,因爲每個對象都有兩個同名的對象。現在我知道如何做到這一點,多循環的很長一段路,而且它不夠優雅。任何人有任何快速的1-2班輪做到這一點?對CSV ::行對象
所以這是數組:
[#<CSV::Row "name":"eee.xxx" "time":"2014-10-31T15:35:14+00:00" "records":"98">,
#<CSV::Row "name":"eee.yyy" "time":"2014-10-31T15:35:30+00:00" "records":"207">,
#<CSV::Row "name":"sss.zzz" "time":"2014-10-31T15:35:44+00:00" "records":"205">,
#<CSV::Row "name":"sss.qqq" "time":"2014-10-31T15:35:59+00:00" "records":"220">,
#<CSV::Row "name":"sss.www" "time":"2014-10-31T15:36:15+00:00" "records":"220">,
#<CSV::Row "name":"eee.xxx" "time":"2014-10-31T15:36:30+00:00" "records":"99">,
#<CSV::Row "name":"eee.yyy" "time":"2014-10-31T15:36:42+00:00" "records":"210">,
#<CSV::Row "name":"sss.zzz" "time":"2014-10-31T15:36:57+00:00" "records":"225">,
#<CSV::Row "name":"sss.qqq" "time":"2014-10-31T15:37:12+00:00" "records":"210">,
#<CSV::Row "name":"sss.www" "time":"2014-10-31T15:37:25+00:00" "records":"230">]
我想用這樣的哈希落得:
{"eee.xxx" => [98,99],
"eee.yyy" => [207,210],
"sss.zzz" => [205,225],
"sss.qqq" => [220,210],
"sss.www" => [220,203]}
任何想法?
非常感謝你,工作就像一個魅力! ;) – 2014-11-05 11:07:51