Thanks for your help!
I need to create a nested JSON file and the first step is to create a dictionary of dictionaries. The below should provide a minimum working example.
Pkg.add("Random")
#Sample of desired keys and categories randomly generated
investmentkeys = string.(zeros(110))
yearkeys = string.(collect(1:12))
valuekeys = string.(zeros(13))
for i in 1:length(investmentkeys)
investmentkeys[i] = randstring(5)
end
for i in 1:length(valuekeys)
valuekeys[i] = randstring(3)
end
#Generating sample data
data = rand(length(investmentkeys), length(yearkeys),
length(valuekeys))
#Create the first level dictionary
dictdata = Dict(agekeys[i] => data[i,:,:] for i=1:length(investmentkeys)
Dict{String, Matrix{Float64}}
The highest level of the dictionary should be the 110 investment names; each contain a 12x13 matrix.
I’d like to then use the yearkeys to split each matrix into a subset dictionary, which contrains a vector of values. I think the result would be:
Dict{String, Dict(String, Vector{Float64}}
How can I create a dictionary of dictionaries with a for loop?
Thank you!