8
$\begingroup$

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"]]

produces:

TreeForm of a WolframAlpha query

Is there a better way?

$\endgroup$
5
  • 6
    $\begingroup$ "staring blankly at waves of curly braces" is a song by Pink Floyd $\endgroup$ Commented Oct 24, 2013 at 0:09
  • 1
    $\begingroup$ TableForm works pretty well for that particular example. $\endgroup$
    – C. E.
    Commented Oct 24, 2013 at 0:25
  • 1
    $\begingroup$ Is something like this what you are looking for? mathematica.stackexchange.com/questions/29339/… $\endgroup$ Commented Oct 24, 2013 at 1:46
  • $\begingroup$ Or this? $\endgroup$
    – cormullion
    Commented 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
    Commented Oct 24, 2013 at 21:39

1 Answer 1

3
$\begingroup$
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

$\endgroup$
1
  • $\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
    Commented 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.