I have a table with numerous columns. I'm trying to take the data from one of the columns and return it as a string.
For instance, if I had:
A B C
1 2 3
4 5 6
7 8 9
I would like to take column B and store 258 as a string. How would I do this?
I have a table with numerous columns. I'm trying to take the data from one of the columns and return it as a string.
For instance, if I had:
A B C
1 2 3
4 5 6
7 8 9
I would like to take column B and store 258 as a string. How would I do this?
Like this?
q)raze exec string B from ([] A:1 4 7;B:2 5 8;C:3 6 9)
"258"
Or are you trying to change the type of the column in the table?
q)update string B from ([] A:1 4 7;B:2 5 8;C:3 6 9)
A B C
--------
1 ,"2" 3
4 ,"5" 6
7 ,"8" 9
If all your entries are single digit numbers, all you need to do is
.Q.n t.B
Taking your data as an example,
q)show t:([] A:1 4 7;B:2 5 8;C:3 6 9)
A B C
-----
1 2 3
4 5 6
7 8 9
q).Q.n t.B
"258"
Note that .Q.n
is simply a string containing the 10 digits:
q).Q.n
"0123456789"
If you want to store the string back in the table, just use update
:
q)update .Q.n B from `t
`t
q)t.B
"258"