As a learning exercise I’m trying to convert some data we have from spreadsheets into an association of associations. However, I’ve only managed to format two different associations, a key of the element’s area and a list of elements in each group (1-49). I’ve tried things like ReplaceMap
, KeyMap
, and AssociationMap
but I’m missing some logic for all these approaches to work. An association of associations seems like an excellent & natural way to structure this data but I can’t figure out how to do it. I’m trying to associate each element’s area to the matching element in the group so that further computation and manipulation can been done. I’d eventually like the ability to add other characteristics to each element type beyond just its area.
Element Key unitkey
<| S1-01->569, S1-02->518, S1-03->461.5, S1-04->570.6, S1-05->617.3, S1-06->631.4
, S1D-01->571.7, S1D-02->647.4,S1D-03->762.2,S1D-04->687.3,S1D-05->691.5,S1D-06->756.4,S1D-07->653.5,S1D-08->783.2,S1D-09->639.3
, S2-01->867.1,S2-02->809.3,S2-03->974.1,S2-04->826.4,S2-05->852,S2-06->852.5,S2-07->865.4,S2-08->865.2,S2-09->1023.4
,S2D-01->890, S2D-03->965.2,S2D-04->861.8,S2D-05->1028.9,S2D-06->986.1,S2D-08->1074.4,S2D-09->1062.6,S2D-10->1007.5
, TH-04->1488,TH-03->1424,TH-02->1352,TH-01->1312
|>
Elements by Group unitsbylevel
<|1 -> {"TH-01", "TH-02", "TH-03", "TH-04"},
2 -> {"S2D-09", "S1D-09", "S1-05", "S1-06"},
3 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03","S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
4 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
5 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
6 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
7 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
8 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
9 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
10 -> {"S2-04", "S2D-09", "S1D-01", "S1-01", "S1-01", "S1D-03", "S2D-05", "S2-03", "S2-06", "S2-07", "S2D-04"},
11 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-08", "S2D-05", "S2D-06", "S2-05", "S2D-01", "S2-08"},
12 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-08", "S2D-05", "S2D-06", "S2-05", "S2D-01", "S2-08"},
13 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-08", "S2D-05", "S2D-06", "S2-05", "S2D-01", "S2-08"},
14 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-08", "S2D-05", "S2D-06", "S2-05", "S2-08"},
15 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
16 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
17 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
18 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
19 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
20 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
21 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
22 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
23 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
24 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
25 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
26 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
27 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
28 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
29 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
30 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
31 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
32 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
33 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
34 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
35 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
36 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
37 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
38 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
39 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
40 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
41 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
42 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
43 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
44 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
45 -> {"S1D-07", "S2-01", "S1-03", "S1-03", "S1D-06", "S1-04", "S1D-04", "S1-02", "S1-02", "S2-02"},
46 -> {"S2D-08", "S1D-02", "S2D-10", "S2-09", "S1D-05", "S2D-03"},
47 -> {"S2D-08", "S1D-02", "S2D-10", "S2-09", "S1D-05", "S2D-03"},
48 -> {"S2D-08", "S1D-02", "S2D-10", "S2-09", "S1D-05", "S2D-03"},
49 -> {"S2D-08", "S1D-02", "S2D-10", "S2-09", "S1D-05", "S2D-03"}
|>
Update 2018-08-23
Added an example of what group 2 would theoretically look like.
<|2 -> <| S2D-09 -> 1062.6 , S1D-09 -> 639.3, S1-05->617.3, S1-06->631.4 |> |>
Import[file.xlsx]
to work with? Can be 5x5x5. And a corresponding result? $\endgroup$<| S2D-09 -> 1062.6...
is an invalid mma syntax, you are missing quotes aroundS2D-09
:"S2D-09"
, so if you want anyone to play with your data you should provide a valid one. $\endgroup$AssociationMap[elementKeyAssociation]
on each of the lists of keys. $\endgroup$