kdb+

how to concatenate list of strings into one long string kdb


I have a list of strings like this

q)select id from temp
id                               
---------------------------------
,"_"                             
"01coin"                         
"0chain"                         
"0dog"                           
"0-knowledge-network"            
"0-mee"                          
"0vix-protocol"                  
"0x"                             
"0x0-ai-ai-smart-contract"       
"0x678-landwolf-1933"            
"0xanon"                         
"0xcoco"                         
"0xdao"                          
"0xgasless-2"                    
"0xgen"
...                  

I need it to look like this

"_,01coin,0chain,0dog,0-knowledge-network,0-mee,0vix-protocol,...etc..."                  

What is the best approach to concatenate such a list into a single string in kdb ? Should I turn my "strings" into `symbols and then vs :/ them ??? I got this far but I don't know how to turn this list of "strings"; into a single "string,..."

("_,";"01coin,";"0chain,";"0dog,";"0-knowledge-network,";"0-mee,";"0vix-protocol,"; ...)

Solution

  • This should work.

    exec”,”sv id from temp
    exec((”,”sv id),”,”)from temp / with a trailing ,
    

    sv converts vector into a scalar. In this case a list of string into a string.

    See: https://code.kx.com/q/ref/sv/

    vs is the opposite.