# Nested Dict can't figure out how to traverse the structure

**URL:** <https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704>\
**Category:** New to Julia\
**Tags:** dictionaries\
**Created:** [June 13, 2022, 8:39pm UTC](https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704 "2022-06-13T20:39:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Post date:** [June 13, 2022, 8:39pm UTC](https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704/1 "2022-06-13T20:39:45Z")

</div>

I am trying to populate a dash table and think the issue is that I don’t know how to traverse a nested dict properly. I have a Dict

```julia
data_flow = 
       Dict{String, Any}("AMZN" => Dict{String, Any}("hv10" => "45.99", "price" => "122.16", "iv_%" => "83.4", "hv20" => "52.14", "iv" => "40.64", "hv5" => "41.21", "prc_%" => "7.51"), "VZ" => Dict{String, Any}("hv10" => "13.87", "price" => "51.27", "iv_%" => "65.61", "hv20" => "12.71", "iv" => "17.62", "hv5" => "10.32", "prc_%" => "19.37"), "C" => Dict{String, Any}("hv10" => "21.26", "price" => "51.78", "iv_%" => "72.73", "hv20" => "42.75", "iv" => "31.75", "hv5" => "20.79", "prc_%" => "11.86"), "IEX" => Dict{String, Any}("hv10" => "19.16", "price" => "195.55", "iv_%" => "70.36", "hv20" => "24.97", "iv" => "27.62", "hv5" => "18.77"))

```

so to get my column headings for dash I need to isolate out

```julia
               HV_10 PRICE IV_% hv20 iv hv5 prc_%

```

but I can’t figure out how to do it.

I can get the rows

```julia
keys(data_flow)

julia> keys(data_flow)
KeySet for a Dict{String, Any} with 4 entries. Keys:
  "AMZN"
  "VZ"
  "C"
  "IEX"

```

and the values for the table

```julia
values(data_flow)

ValueIterator for a Dict{String, Any} with 4 entries. Values:
  Dict{String, Any}("hv10" => "45.99", "price" => "122.16", "iv_%" => "83.4", "hv20" => "52.14", "iv" => "40.64", "hv5" => "41.21", "prc_%" => "7.51")
  Dict{String, Any}("hv10" => "13.87", "price" => "51.27", "iv_%" => "65.61", "hv20" => "12.71", "iv" => "17.62", "hv5" => "10.32", "prc_%" => "19.37")
  Dict{String, Any}("hv10" => "21.26", "price" => "51.78", "iv_%" => "72.73", "hv20" => "42.75", "iv" => "31.75", "hv5" => "20.79", "prc_%" => "11.86")
  Dict{String, Any}("hv10" => "19.16", "price" => "195.55", "iv_%" => "70.36", "hv20" => "24.97", "iv" => "27.62", "hv5" => "18.77")

```

can someone help me isolate out the column headings in this Dict of dicts.

I’m trying to get this into dash

```julia
             HV_10 PRICE IV_% hv20 iv hv5 prc_%
AMZN 45.99 122.16 83.4 52.14 40.64 41.21 7.51
VZ 13.87 51.27 65.61 12.71 17.62 10.32 19.37
C 21.26 51.78 72.73 42.75 31.75 20.79 11.86
IEX 19.16 195.55 70.36 24.97 27.62 18.77

```

thank you

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [June 13, 2022, 8:48pm UTC](https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704/2 "2022-06-13T20:48:21Z")

</div>

> [@anon69491625](#):
>
> ```julia
> data_flow = 
> Dict{String, Any}("AMZN" => Dict{String, Any}("hv10" => "45.99", "price" => "122.16", "iv_%" => "83.4", "hv20" => "52.14", "iv" => "40.64", "hv5" => "41.21", "prc_%" => "7.51"), "VZ" => Dict{String, Any}("hv10" => "13.87", "price" => "51.27", "iv_%" => "65.61", "hv20" => "12.71", "iv" => "17.62", "hv5" => "10.32", "prc_%" => "19.37"), "C" => Dict{String, Any}("hv10" => "21.26", "price" => "51.78", "iv_%" => "72.73", "hv20" => "42.75", "iv" => "31.75", "hv5" => "20.79", "prc_%" => "11.86"), "IEX" => Dict{String, Any}("hv10" => "19.16", "price" => "195.55", "iv_%" => "70.36", "hv20" => "24.97", "iv" => "27.62", "hv5" => "18.77"))
> 
> ```

I’m not sure I understand the problem but does this help in any way?

```julia
julia> collect(keys(data_flow["VZ"]))
7-element Vector{String}:
 "hv10"
 "price"
 "iv_%"
 "hv20"
 "iv"
 "hv5"
 "prc_%"

```

---

<div class="post-metadata">

**Author:** ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Post date:** [June 13, 2022, 8:57pm UTC](https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704/3 "2022-06-13T20:57:53Z")

</div>

Hi there

thanks for looking at this for me. That’s spot on but can I just get the first entry in the dict as all I want is the string vector. “VZ” might not be there so I can’t hard code it.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [June 13, 2022, 8:59pm UTC](https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704/4 "2022-06-13T20:59:26Z")

</div>

Sure.

```julia
julia> collect(keys(first(values(data_flow))))
7-element Vector{String}:
 "hv10"
 "price"
 "iv_%"
 "hv20"
 "iv"
 "hv5"
 "prc_%"

```

---

<div class="post-metadata">

**Author:** ![anon69491625](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@anon69491625](https://discourse.julialang.org/u/anon69491625)\
**Post date:** [June 13, 2022, 9:07pm UTC](https://discourse.julialang.org/t/nested-dict-cant-figure-out-how-to-traverse-the-structure/82704/5 "2022-06-13T21:07:16Z")

</div>

at some point I will have a brain fitted that will work. In my defense…  
actually there is no defense I should be able to figure this stuff out.  
thank you so much for the assist.
