kgf3JfUtW
kgf3JfUtW

Reputation: 14926

kdb: Use \l to load a data file (table vs list)

In examples provided by https://code.kx.com/q4m3/11_IO/#1113-serializing-and-deserializing-q-entities

I found that I can use \l to load back a table, but cannot load back a list. Am I missing something, or does \l only support loading back data of certain types?

table

`:/tmp/data/t set ([] c1:`a`b`c; c2:10 20 30)
get `:/tmp/data/t
\l /tmp/data/t  / OK

list

`:/tmp/data/L set 10 20 30
get `:/tmp/data/L
\l /tmp/data/L  / 'type

Upvotes: 0

Views: 1645

Answers (2)

Callum Biggs
Callum Biggs

Reputation: 1550

I believe this may be a genuine bug, from the documentation \l should load in any q serialized file. However I would advise against using \l to load in files, for the following reasons

  • When loading enumerated partition table, it's very easy to not load the associated sym file and then have no symbols (see the example below)
  • Files are loaded in with the name of the file, which can overwrite objects, it's much better to use get
q)t:.Q.en[`:tmp;([] c1:`a`b`c; c2:10 20 30)]
q)`:/tmp/data3/t/ set t
`:/tmp/data3/t/
q)\\

C:\Users\cbiggs\Documents>q
KDB+ 4.0 2020.05.04 Copyright (C) 1993-2020 Kx Systems
w64/ 8(16)core 16227MB cbiggs lptp633 192.168.56.1 EXPIRE 2021.05.18 [email protected] KOD #4170988

q)\l /tmp/data3/t
`t
q)t
c1 c2
-----
0  10
1  20
2  30

Upvotes: 1

Cathal O'Neill
Cathal O'Neill

Reputation: 3179

You can load the list into memory by loading the directory in which it lies

q)`:/tmp/data/L set 10 20 30
`:/tmp/data/L
q)\l /tmp/data/
q)L
10 20 30

Upvotes: 2

Related Questions