English 中文(简体)
How to convert a list of symbols to strings and then split by a delimiter
原标题:
  • 时间:2023-08-22 02:12:00
  •  标签:
  • kdb

Say I have a list of symbols like so...

q) list
`hello_world.q
`hello_world_2.q

I d like to split this so I end up with this list of strings...

q) new_list
"hello_world"
"hello_world_2"

how is that done?

I can do this using something like...

string1: "`" vs string list[0]
string1: "." vs string1[1]

But not sure how to do the full list

问题回答

You can use vs, each and each right (/:):

q)string first each` vs/:`hello_world.q`hello_world_2.q
"hello_world"
"hello_world_2"

Use case of vs is documented here: https://code.kx.com/q/ref/vs/#symbol-by-dot

Alternatively:

q)string(` vs `hello_world.q`hello_world_2.q)[;0]
"hello_world"
"hello_world_2"




相关问题
Concat string with number in kdb+ q

I can append a string with number. temp:30 text:"Current temperature is ",string temp show text type text Result "Current temperature is 30" 10h However, if I append one more ...

How do I save a program in kdb/q?

Most of the examples seem to be run in REPL mode. Is it possible to load myprog.q from disk?

Q (kdb): nested where query

What are the ways to in Q to use the results of a nested query in a where clause? I m looking for something similar to SQL statement. select from food where type_id in ( select type_id from ...

Passing db path to l or .Q.l using a variable

I m writing a q script that loads a db in a particular path and does some processing on it. The location of the db is currently hardcoded in the script, but I want to pass the db path as an argument ...

How to convert tic data to 5 minute OHLC?

I am learning KDB+ and have loaded the tic data into the table W as below. My question is, how to transfer the data into 5 (or n) minutes OHLCVA? "Stk_ID","Date","Time","Price","Chg","Vol","Amt","Ty" ...

KDB Find first date with data in each table of a process

I am trying to find first date where we have data available per process over IPC. I tried below but it isn t efficient. Is there a better way to find this? select min date from ({select date from x ...

热门标签