stupidkidyoyo
stupidkidyoyo

Reputation: 21

Retrieving splayed tables in q kdb

I tried the following code to retrieve the splayed table, but in vain. After loading sym, the table still leaves its symbol columns as bare enumerations.

\l dir/file
load `:dir/file/sym
get `:/dir/file/

Here is the file structure

file 
-sym 
-col1
-col2
-col3
-.d

Please help

Upvotes: 0

Views: 926

Answers (2)

check if you are enumerating the file for any missed symbols. when you are writing the data to the splayed table.

.Q.en[`dir/file]

Upvotes: 0

CWD
CWD

Reputation: 353

So in this example "file" is your table and you should have another sym file (which is a distinct list of symbols the enumerated columns map to) in the same directory as your table. So in your directory 'dir' there should exist a sym file, and that is what you need to load rather that just the column called sym, which is what you are doing.

Here is a working example for you, first 2 lines after exiting and re-starting q show what the issue is in your code.

q)t:([]sym:10?`2;time:.z.t;alpha:til 10)
q)`:newDir/t/ set .Q.en[`:newDir]t
`:newDir/t/
q)
q)\\

C:>q
q)get`:newDir/t/sym
`sym!0 1 2 3 4 5 4 6 4 7
q)get`:newDir/sym
`mi`ig`ka`ba`kf`je`lk`fg
q)get`:newDir/t
sym time         alpha
----------------------
0   06:07:57.191 0
1   06:07:57.191 1
2   06:07:57.191 2
3   06:07:57.191 3
4   06:07:57.191 4
5   06:07:57.191 5
4   06:07:57.191 6
6   06:07:57.191 7
4   06:07:57.191 8
7   06:07:57.191 9
q)load`:newDir/sym
`sym
q)get`:newDir/t
sym time         alpha
----------------------
mi  06:07:57.191 0
ig  06:07:57.191 1
ka  06:07:57.191 2
ba  06:07:57.191 3
kf  06:07:57.191 4
je  06:07:57.191 5
kf  06:07:57.191 6
lk  06:07:57.191 7
kf  06:07:57.191 8
fg  06:07:57.191 9

Upvotes: 1

Related Questions