KX Community

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

Home Forums kdb+ How to remove an empty symbol from q dictionary

  • How to remove an empty symbol from q dictionary

    Posted by aakash on July 3, 2023 at 12:00 am
    2023.03.10| data.log202303120859 
    2023.03.11 | data.log202303120859 
                        | data.log202303120859 
    2023.03.12| data.log202303120859 data.log202303131959
    2023.03.13| data.log202303131959

    Here i want to remove the null value from date 2023.03.13

    > logs:`data.log202303120859,`data.log202303131959;
    > l:{
    > datalog:read0 `$":/path/value/",string x;
    > d:exec distinct("d"$"p"$"Z"$incomingTimestamp) from (.j.k each datalog);
    > raze x{ (enlist y)!enlist x}/: d
    > each logs
    > (,'/)l
    aakash replied 9 months, 2 weeks ago 2 Members · 4 Replies
  • 4 Replies
  • davidcrossey

    Member
    July 3, 2023 at 12:00 am

    You could use except each as follows:

    q)d:(2023.03.12 2023.03.13)!(`data1.log`data2.log;“data3.log) q)d 2023.03.12| data1.log data2.log 2023.03.13| data3.log q)d except’ ` 2023.03.12| `data1.log`data2.log 2023.03.13| ,`data3.log

  • davidcrossey

    Member
    July 3, 2023 at 12:00 am

    If you mean remove the null key, you can drop the null using the following syntax:

    q)show d:(4?(0Nd,3?.z.D))!1 2 3 4 2006.11.03| 1 2008.12.03| 2 | 3 | 4 q)enlist[0Nd] _ d 2006.11.03| 1 2008.12.03| 2

  • aakash

    Member
    July 3, 2023 at 12:00 am
    2023.03.12| data.log202303120859 data.log202303131959
    2023.03.13|                      data.log202303131959

    sorry i missed in the above question. i want to remove the null value from 2023.03.13. the key 2023.03.13 has an null value in the dictionary stored as a symbol.

    > dict[2023.03.13]

    “ `data.log202303131959

  • aakash

    Member
    July 3, 2023 at 12:00 am

    Thanks

Log in to reply.