I want to create a nested Dict from a list of data. I think it’s clear from this non-working example what I want to do:
# make dummy data n = 1000 r = [rand(string.('A':'Z'), n, 5) rand(n,1)] # build a nested Dict nested = Dict() # or Dict(Dict(Dict(...))) or whatever for i=1:n a,b,c,d,e = r[i,1:5] nested[a][b][c][d][e] = r[i,6] end
What is the most compact and elegant way of building this structure without creating key combinations not in the list, and without descending too far into
haskey() hell? Extra brownie points if the Dicts are correctly typed instead of using Any.