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
2
votes
1 answer

Selecting rows based on column contents which are in a list in kdb

I have a list called 'A' as: cont "aa" "bb" "cc" I have a table called 'run' containing columns first second third sad random "aa" happy random1 "dd" I have to select those rows from…
user8415577
2
votes
4 answers

How to create string/list of string with symbol in kdb?

I have a table with one column of strings, I want to create a new column with type string, and ` in front of each string item. How do I do that? example: Old: a b c New: "\`a" "\`b" "\`c"
Deb
  • 35
  • 1
  • 6
2
votes
1 answer

Is there a more scalable sub-select alternative to this query?

I have a large table that contains a date field of type datetime. As part of a function that takes as input two lists of datetime namely a list of afroms and atos I'd like to compute for each of these afrom,ato pairs all the rows of the large table…
SkyWalker
  • 13,729
  • 18
  • 91
  • 187
2
votes
2 answers

Sublime and q files Automatic Build Setup, on Mac OS

I am working with Sublime and also running some q/kdb scripts from Sublime. I have a "q Build" set up and works fine when I manually change the build. But I tend to switch between q and other languages quiet often and each time I need to manually…
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
2
votes
1 answer

q - No speed gain for data normalisation via enumerations

In the q for mortals chapter on data normalisation, i.e. the task of eliminating duplication in a list, it recommends using enumerations for finding distinct values in a list as its faster to traverse over integers than it is over symbols of…
tenticon
  • 2,639
  • 4
  • 32
  • 76
2
votes
1 answer

I am a beginner in Q. Got multiple questions related to Q

When I type l: 1 2, I get back list of 1,2. But when I type string: a b, why I get back `assign? What does ` sign does in Q? What is its significance?
Munish
  • 21
  • 3
2
votes
1 answer

compiling qml in macOS kdb+/q (CFLAG?)

I have an issue with compiling qml in my macOS environment. I am not from IT background so I do not fully understand every detail in compiling C/C++ programs. I have attempted to compile qml library on my macOS-- but I have been getting this error:…
jeonw
  • 123
  • 8
2
votes
5 answers

KDB using function in where clause

Is there a way in kdb to use functions in queries. assume I have a table with columns `red`blue`green`yellow`white`purple which contain either values 0 or 1. Instead of querying select where ((red=1) or (green=1)) can I use a function…
chrise
  • 4,039
  • 3
  • 39
  • 74
2
votes
3 answers

kdb/q: Query multiple handles with hopen

I would like to be able to query several handles at once, where the tables have the same format like: handles: 8000,8001,8003 tables: foo Want to do something like: x:hopen `8000`8001`8003 x select from foo col1,col2 So i get rows from each foo…
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
2
votes
2 answers

How do I remove the first or last n characters from a value in q/ kdbstudio?

I've looked into the underscore for drop/cut, but this only seems to remove the first or last n entries, not characters. Any ideas?
Anna
  • 825
  • 1
  • 11
  • 19
2
votes
1 answer

KDB appending tables with different columns

I have two tables, that have some columns in common and some columns that the other table does not have. atab:flip `items`sales`prices`athing!(`anut`abolt`acam`acog;6 8 0 3;10 20 15 20; 50.2 32.6 1.18 -3.9) btab:flip…
chrise
  • 4,039
  • 3
  • 39
  • 74
2
votes
2 answers

kdb/q: Increase visible rows in browser

Hi I am running kdb and usually use the browser for basic viewing of the tables by running the kdb on a port: \p xxx My questions is how can I increase the visible rows in the browser? Currently I believe there is a fixed number of rows that are…
Alim Hasanov
  • 197
  • 1
  • 3
  • 16
2
votes
1 answer

matrix multiplication across tables in kdb

I want to multiply all the values in a 4x2 table by a 2x1 table, and get back a 4x1 vector (ideally a column in a table). How do I convert the data in kdb tables into matrices to permit matrix mulplication? tab2:([]w:1 3 2 1; x:-6 8 0 -3); taby:([]…
user7613376
2
votes
1 answer

Understanding moving window calcs in kdb

I'm struggling to understand this q code programming idiom from the kx cookbook: q)swin:{[f;w;s] f each { 1_x,y }\[w#0;s]} q)swin[avg; 3; til 10] 0 0.33333333 1 2 3 4 5 6 7 8 The notation is confusing. Is there an easy way to break it down as a…
user7613376
2
votes
2 answers

Are there any other native hashing methods such as SHA1/256 besides MD5 on kdb+?

A quick search only yields this for MD5: http://code.kx.com/q/ref/strings/#md5 Are there any other ways to implement SHA1/SHA256 without writing it yourself?
kenwjj
  • 341
  • 1
  • 7
  • 21