Home › Forums › kdb+ › Lists, dictionaries, tables and lists of dictionaries › Re: Lists, dictionaries, tables and lists of dictionaries
-
Hey Rian/Sam,
I finally got around to investigating this more fully.
The issue I have comes down to the below example of a nested data structure called dsEg here.
dsEg: (`doctype`html)!(enlist “html”;`text`body!(enlist”test”;enlist ([]a: `d`f`g;b: 23 43 777)));
My problem is that I don’t know how to use apply (@;.) to get to the columns on that nested table ([]a: `d`f`g;b: 23 43 777).
I feel like it should be
cols .[dsEg;(`html;`body;0)]
since the table is enlisted which means it’s in a single element list.
However, I can’t get it, or any other approach to work using Apply alone so I can’t use Apply as a method to traverse any general data structure in cases like the above where the structure descends within a nested table. The best I can do is get to the layer above and apply raze. I know that sounds like a small thing but the problem comes when nesting then continues down into the table – there is no way to use apply with a list of keys to get past that application of raze at the table level.
Building a function which will allow that to work was ultimately the motivation for this whole tangent. I think I now appreciate that Apply is intended to be fully generic so I’m basically reinventing the wheel. However, to help me abandon my method, can you advise how Apply might be used with a list of keys to get to the column names or any other nested elements within that table?
Regards,
Simon