Utsav
Utsav

Reputation: 5918

remove few items from a list in kdb

Below is a list of tables

q)tables[]
`abc`def`j`l_data`l_data1`l_data2`s`t

I'm trying to remove few tables name from the list of table names, and failing miserably, after lot of effort could think of below code which is not providing expected output

(string each tables[])_/:(string each tables[])?("def";"l_data*") 
/ Trying to remove tables - def, all table names like l_data*
/ Expected output - `abc`j`s`t

Can't think of a solution using inter.

Upvotes: 1

Views: 770

Answers (2)

Phil
Phil

Reputation: 111

You could alternatively avoid the each right adverb and the all function by using except as such:

(tables[] where not tables[] like "l_data*") except `def

Also worth noting that the string conversions aren't necessary to use regex

Upvotes: 1

Rahul
Rahul

Reputation: 3969

 q) a where all not (a:tables[]) like/: ("def";"l_data*")

Upvotes: 4

Related Questions