Access VBA 質問スレ Part2 (788レス)
Access VBA 質問スレ Part2 http://mevius.5ch.net/test/read.cgi/tech/1544620479/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
112: デフォルトの名無しさん [sage] 2019/09/28(土) 23:50:31.47 ID:Bvcc+55+ Ruby なら、 require 'csv' str = <<"EOT" id 部門 販売品目 1 A りんご 2 A バナナ 3 A りんご 4 B バナナ 5 B ぶどう 6 B ぶどう EOT # 空白区切りで、ヘッダー有り options = { :headers => true, :col_sep => " " } # Hash.new で、初期値は、{ } hash = CSV.parse( str, options ).each_with_object( Hash.new { |h,k| h[ k ] = { } } ) do | row, hash | dep = row[ '部門' ] # department item = row[ '販売品目' ] if hash.dig( dep, item ) # Ruby 2.3 から hash[ dep ][ item ] += 1 else hash[ dep ][ item ] = 1 end end p hash #=> {"A"=>{"りんご"=>2, "バナナ"=>1}, "B"=>{"バナナ"=>1, "ぶどう"=>2}} http://mevius.5ch.net/test/read.cgi/tech/1544620479/112
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.038s