So for some reason I can print the keys of a dictionary and access elements of a dictionary in a loop but I cannot do it outside of the loop. Any advice as to how to fix this would be very much appreciated.
`nodedata_dict = Dict(pairs(eachcol(nodedata_data)))
counter = 0
for (key, value) in nodedata_dict
if counter <= 2
println("Key:$key, Value: $value")
println(key in keys(nodedata_dict))
println(nodedata_dict[key])
counter += 1
end
end
println("ok can we get this node right",nodedata_dict["pwpl_idno_12184"])`
Output is as follows:
Key:pwpl_idno_12184, Value: [0.0, 0.0, 0.0] true [0.0, 0.0, 0.0] Key:rwst_idno_1721, Value: [0.0, 0.0, 0.0] true [0.0, 0.0, 0.0] Key:rwst_idno_2068, Value: [0.0, 0.0, 0.0] true [0.0, 0.0, 0.0] KeyError: key "pwpl_idno_12184" not found
So basically I can print out a few keys including "pwpl_idno_12184" but then when I try to access that key I get an error indicating that key that I just printed from the dictionary does not exist.
ok I fixed this - the keys were Symbol type not Strings hence to call the keys I had to use :keytext instead of "keytext".