When interacting with Mathematica, I often find myself staring blankly at waves of curly braces, trying to understand how data is organized hierarchically. For example, the beginning of the result to

WolframAlpha["temperature in Toronto yesterday", "DataRules"]

looks like this:

Waves of curly braces

To visualize the hierarchy, I typically turn to TreeForm, but that's often unwieldy. There's no way to collapse parts of the tree you don't care about (as there would be in, say, a file system browser), so the visualization frequently spreads well off screen or is illegibly small. For example,

TreeForm[WolframAlpha["temperature in Toronto yesterday", "DataRules"]]


TreeForm of a WolframAlpha query

Is there a better way?

  • 6
    $\begingroup$ "staring blankly at waves of curly braces" is a song by Pink Floyd $\endgroup$ Oct 24, 2013 at 0:09
  • 1
    $\begingroup$ TableForm works pretty well for that particular example. $\endgroup$
    – C. E.
    Oct 24, 2013 at 0:25
  • 1
    $\begingroup$ Is something like this what you are looking for? mathematica.stackexchange.com/questions/29339/… $\endgroup$ Oct 24, 2013 at 1:46
  • $\begingroup$ Or this? $\endgroup$
    – cormullion
    Oct 24, 2013 at 6:52
  • $\begingroup$ Thanks for the lead, @Mike. TraceView led me to the OpenerTree example in Virtual Book, which is a good start. $\endgroup$
    – duozmo
    Oct 24, 2013 at 21:39

1 Answer 1

data = WolframAlpha["temperature in Toronto yesterday", "DataRules"];

Is this enough?

Column[OpenerView[{#, Switch[Head[#2], 
   List, Pane[Column@#2, {Full, 200}, Scrollbars -> True], 
   _, #2]}
] & @@@ data]

enter image description here

  • $\begingroup$ Certainly works well for Wolfram Alpha output, which has a consistent nesting structure. For arbitrarily nested lists, I'm still using OpenerTree from Virtual Book. $\endgroup$
    – duozmo
    Nov 14, 2015 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.