KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Lists, dictionaries, tables and lists of dictionaries Re: Lists, dictionaries, tables and lists of dictionaries

  • rocuinneagain

    Member
    January 6, 2022 at 12:00 am

    As in the example it is a nested generic list the items need to be dealt with one at a time. As the list could have many different tables or even different datatypes within it.

    q)cols each .[dsEg;(`html;`body)] 
    a b 
    q).[dsEg;(`html;`body);{cols each x}] 
    doctype| ,"html" 
    html   | `text`body!(,"test";,`a`b)

    The use of  :: may be useful to you if you have not been using it

    https://code.kx.com/q/ref/apply/#nulls-in-i

    It allows you to skips levels

    q).[dsEg;(`html;`body;::;`a)] 
    d f g //Better shown on an item with multiple entries in the list 
    q)dsEg2:(`doctype`html)!(enlist "html";`text`body!(enlist"test";2#enlist ([]a: `d`f`g;b: 23 43 777))); 
    q).[dsEg2;(`html;`body;::;`a)] 
    d f g d f g

     

    .Q.s1 may also be useful to you as it can help show the underlying structure of an item better than the console at times.

    https://code.kx.com/q/ref/dotq/#qs1-string-representation

    q).[dsEg;(`html;`body;::;`a)] 
    d f g //Looks like a symbol list type 11h but is in fact a single item egeneric list type 0h 
    q){-1 .Q.s1 x;} .[dsEg;(`html;`body;::;`a)] 
    ,`d`f`g //.Q.s1 output can be ugly but always shows exact structure