I have a hierarchical but row based spreadsheet file that looks like this when imported :

stuff = {{"Level1a", , , }
, {"Level1a", "Level2a", ,}
, {"Level1a", "Level2a", "Level3a",}
, {"Level1a", "Level2a", "Level3b",}
,  {"Level1a", "Level2a", "Level3b", "Level4a"}
, {"Level1a", "Level2a", "Level3b", "Level4b"}
, {"Level1b", , , }
, {"Level1b", "Level2b", "Level3c",}
, {"Level1b", "Level2b", "Level3d",}} // TableForm

I would like to arrange it into rows and columns like below except for some reason the align top doesn't work :

Column[{"Level2a", Column[{" Level3a", " Level3b"}], "Level2b"}], 
" Level1b", Column[{"Level2c", "Level2d"}]}, 
Alignment -> {Top, Top}]

(* Actual result wanted :
   Level1a      Level1b
     Level2a      Level2c
        Level3a      Level3c
     Level2b    *)

My objective is 2 fold : 1. Reformat the data.

This is how far I have got on the reformatting - I can get Parent-Child pairs :

DeleteDuplicates[Flatten[Partition[stuff, {1, 2}, 1], 2]]

(* result {{"Level1a", Null}, {Null, Null}, {"Level1a", "Level2a"}, {"Level2a", 
Null}, {"Level2a", "Level3a"}, {"Level3a", Null}, {"Level2a", 
"Level3b"}, {"Level3b", Null}, {"Level3b", "Level4a"}, {"Level3b", 
"Level4b"}, {"Level1b", Null}, {"Level1b", "Level2b"}, {"Level2b", 
"Level3c"}, {"Level3c", Null}, {"Level2b", "Level3d"}, {"Level3d", 
Null}} *)
  1. Introduce Grid/Column/Row as appropriate to create the structure I want. I have already tried Map-ping but can't find a way to get them in the right place.
  • $\begingroup$ Row is not appropriate for what you are trying to accomplish. You should use Grid. See ZachB answer. $\endgroup$
    – m_goldberg
    Feb 13, 2015 at 6:15

1 Answer 1


Is it possible to change structure and use a Grid instead? For example, the below gives you what you want (and it continues to make use of spaces for indentation, which you did in your example attempt).


      " Level2a",
      " Level2c"

      Column[{"  Level3a","  Level3b"}],
      "  Level3c"

    {" Level2b"}
  • $\begingroup$ I was struggling to get grid to work thats partially what I wanted. Im also struggling to reformat the data into something that I can then Map or otherwise introduce Grid and Column too. I'll update my question. $\endgroup$ Feb 13, 2015 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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