Questions tagged [q-lang]

The q language is a programming language by kx.com for querying kdb+ databases.

Q was developed by Arthur Whitney in 2003 and is built on top of the K programming language. The names q and kdb+ are often used interchangeably, but generally q refers to the programming language and kdb+ refers to the entire runtime environment.

245 questions
3
votes
2 answers

Load file.q from path containing space character

How to load script file from a path containing spaces? For example, this works: \l F:/file.q Below attempts throw an error: \l F:/Folder with spaces/file.q \l "F:/Folder with spaces/file.q" \l hsym `$"F:/Folder with spaces/file.q" system "l…
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
3
votes
1 answer

Delete/remove/drop variable in q

I've created a variable in the : q)myvar: 1 How can I delete it? I've tried: q)delete myvar from `.z but the namespace `.z is clearly not the right one, as the variable still does exist: q)myvar 1
Daniel Krizian
  • 4,586
  • 4
  • 38
  • 75
3
votes
2 answers

How to kill KDB queries in RDB or HDB?

We have a ticker plant and sometimes someone mistakenly runs queries in HDB without a date or in RDB without a time or with some other processing logic which may kill KDB. How can we find and kill the query without restarting KDB instance?
user3914448
  • 469
  • 1
  • 11
  • 22
3
votes
3 answers

Get substring into a new column

I have a table that contains a column that has data in the following format - lets call the column "title" and the table "s" title ab.123 ab.321 cde.456 cde.654 fghi.789 fghi.987 I am trying to get a unique list of the characters that come before…
spinon42
  • 31
  • 1
  • 2
3
votes
3 answers

extract number from string in kdb

I am quite new to kdb+q. I've come across this problem of extracting a number out of string. Any suggestions? Example: "AZXER_1234_MARKET" should output 1234 //Assume that there is only one number in the string
pikachuchameleon
  • 665
  • 3
  • 10
  • 27
3
votes
2 answers

checking in list from kdb instance

I am storing strings in a list under variable name res. Next, I construct a query that will look into the list of strings. However it seems like the variable is not being read. This is what I mean: q) hdl: (to a port) q) res:…
stretchr
  • 615
  • 2
  • 9
  • 24
3
votes
1 answer

Repeat last statement in the Q shell

The Q programming language has an associated shell. How does one access his last input in the shell? For example, if I type: q) a:45 in the next prompt q), I would like to recover a:45 by hitting the up arrow (as in bash), however, this does not…
Riemann1337
  • 133
  • 3
3
votes
4 answers

How to remove element from list in KDB?

For instance, I have: x: (`a`b!(1;2); (); `a`b!(3;4)) and I want to remove the (). I have tried using ? (match) x[x ? not ()] but that just gives (). What is the correct expression? Background I often use peach to execute a series of queries, and…
mchen
  • 9,808
  • 17
  • 72
  • 125
3
votes
3 answers

How to select first record prior/after a given timestamp in KDB?

I am currently just pulling in all records 1min leading up to the timestamp (e.g. if the timestamp I'm interested in is 2014.04.14T09:30): select from Prices where timestamp within 2014.04.14T09:29 2014.04.14T09:30, stock=`GOOG However, this is…
mchen
  • 9,808
  • 17
  • 72
  • 125
3
votes
4 answers

How to sum across a row in KDB/Q

I have a table rCom which has various columns. I would like to sum across each row.. for example: Date TypeA TypeB TypeC TypeD date1 40.5 23.1 45.1 65.2 date2 23.3 32.2 56.1 30.1 How can I write a q query to add a…
stretchr
  • 615
  • 2
  • 9
  • 24
3
votes
1 answer

(kdb+/q) Is it possible to join or combine rows?

Here is my situation: I currently have a data table that looks something like this: Symbol Date Time Sequence Type --------------------------------------------------------------------------- A 2013.06.06 …
user2498110
  • 105
  • 1
  • 1
  • 9
3
votes
1 answer

Difference in function behavior when called standalone or inside a query in q

I have found a strange issue in q, a possible bug I suppose. I have defined a simple function that returns a float, given a date as input: give_dummy:{[the_date] /// give_dummy[2013.05.10] // <- if u wanna test :$[ the_date > 2013.01.01 ;…
Marco Mene
  • 397
  • 2
  • 6
  • 11
3
votes
1 answer

Output difference when calling string()

I want to concatenate a number of variables having different types into a string. This works well: q)"select ", string[10:00:00] ," abc" "select 10:00:00 abc" When I call string with parenthesis the output is different: q)"select ",…
Robert Kubrick
  • 8,413
  • 13
  • 59
  • 91
2
votes
1 answer

Append columns to empty table - Q/KDB+

I'm pulling data from a source that returns tick data for stocks (timespan + float prices). I need to build 1 table that has the tick data for each stock, while inserting new timespan index values for each one. Example: AAPL: t0 101.20 t3 …
Fomalhaut -C
  • 320
  • 2
  • 13
2
votes
1 answer

q - string representation of list

I have a list filter:((in;`name;`betsy`robert`tom);(>;`age;43)); and I would like to get the following list representation out of it "((in;`name;`betsy`robert`tom);(>;`age;43))" What I found so far is this: flatten:{[alist] $[(count…
tenticon
  • 2,639
  • 4
  • 32
  • 76