cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove an empty symbol from q dictionary

Aakash
New Contributor II

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

1 ACCEPTED SOLUTION

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

View solution in original post

4 REPLIES 4

davidcrossey
Moderator Moderator
Moderator

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
New Contributor II
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

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

Aakash
New Contributor II

Thanks @davidcrossey