table - KDB; stripping characters from column of symbols -


Any ideas what to do well in KDB?

Consider the table

  X: ([] a: 1 2 3; b: `abc11`abc22`abc33; c: 10 20 30)   

I have now taken a new table Y. "ABC" from the symbols in the second column, such as:

  Y: ([] a: 1 2 3; b: `11`22`33; c: 10 20 30)    

  q) T: ([] a: 1 2 3; B: `ABC 11` BC 22 BC 33; C: 10 20 30) Q) Tabasi ---------- 1 ABC 11 10 2 ABC 22 20 3 ABC 33 30   

Strip the first three letters:

  q) Update $ 3_ 'string bee from tabc ------ --- 1 11 10 2 22 20 3 33 30   

or search and replace:

  q) update $$ ssr [; "abc"; ""] Each string of tabc b --------- 1 11 10 2 22 20 3 33 30 If the table is large and there are several repeating items, consider using it. Q.fu:  
  q) T: 1000000 # ([] A: 1 2 3; B: `ABC 11` BC 22 BC 33; C: 10 20 30) Q) \ t R1: Update `$ 3_ 'from string BT 111 quintals) \ t r2: Update .q.fu [{` $ 3_'string x}; b] T5Q) r1 ~ r2 1b    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -