0

I'm working with data packed into nested dictionary with structure that might look like this:

outer_dict
| key1
| | key11
| | | key111: value
| | | key112: value
| | key12: value
| | key13:value
| key2
| | key21: value
| | key22
| | | key221: value
| | | key222
| | | | key2221: value
| key3
| key4 ...

and I don't know yet how many levels it has and what is the data type of each "final" value (and don't have access to detailed documentation of dataset). What is an easy way to examine structure of such data (preferably to visualize in form of graph)? My only idea so far is to write a function that iterates over keys and prints something like above.

This is the beginning of working with that data: enter image description here

Brzoskwinia
  • 371
  • 2
  • 11
  • What is missing from `print(json.dumps(rates, indent=2))` just so that we might better know how to help address any deficiency. – JonSG May 19 '23 at 13:46
  • @JonSG I don't know how exactly it works but `print(json.dumps(rates, indent=2))` gives `TypeError: keys must be str, int, float, bool or None, not tuple` (some of nested keys are tuples) – Brzoskwinia May 19 '23 at 13:49
  • 2
    Maybe this is of interest: [link](https://stackoverflow.com/questions/15023333/simple-tool-library-to-visualize-huge-python-dict) – user19077881 May 19 '23 at 13:58
  • tuples as keys hmm that throws a wrench in the works... let me write a little recursion to see about getting past that. – JonSG May 19 '23 at 14:07
  • @user19077881 your link is helpful and I'll use binnev's answer with `visualize_dict` - its not perfect (because it takes too much place for big dicts) but works for now, maybe later I or someone else here will come up with better idea or modification – Brzoskwinia May 19 '23 at 14:17
  • I have a solution but before I post it, what do you mean by "takes to much space"? I ask because my text based solution will not be as information dense as some of the answers in the link recommended by @user19077881 – JonSG May 19 '23 at 14:22

0 Answers0