Search code examples
kdb

(q/kdb+) Create a table with string column


I can create the following table in kdb using

([]idx:0,1,2;str:"a","b","c")

idx str
0   a
1   b
2   c

but I cant do for instance

([]idx:0,1,2;str:"aa","bb","cc")

I would like to get

idx str
0   aa
1   bb
2   cc

What am I doing wrong when creating this string column?


Solution

  • Use braces and semi-colons rather than commas to separate list items:

    q)([]idx:(0;1;2);str:("aa";"bb";"cc"))
    idx str
    --------
    0   "aa"
    1   "bb"
    2   "cc"