I have information I'm retrieving from a database:
with fields like
|Portfolio| Date | Sector| Industry | Ticker | Price | Postion|
and data like
("us", "2013-01", "Consumer","Retail","PM",10,1000)
("us", "2013-01", "Consumer", "Retail", "JCP", 15, 1500) ...
How can I turn this into a dictionary that looks like:
{us:{"2013-01":{"Consumer":{"Retail":{"PM":{"Price":10,"Position":1000},"JCP":{"Price":15, "Position":1500}}}}}}
in the most time and resource effective way?
something like
a[Date][Sector][Industry][Ticker].update("PM2" = dict(close=10, position = 1000))
gives me an error.
Thanks
{us:{"2013-01":{"Consumer":{"Retail":{"PM":{"Price":10,"Position":1000},"JCP":{"Price":15, "Position":1500}}}}}}its not how dictionaries are meant to be used. Instead put all the key:value pairs in one {} bracket pair