Search code examples
kdb

In q, how to add a symbol to a symbol


I'm trying to load a table with a variable name.

Let's say:

a:`partofurl;

Then this doesn't work:

load `:c:/q/a/table;

So how can I use the variable a in the url symbol expression?


Solution

  • In certain scenarios like this one you can use sv (http://code.kx.com/q/ref/casting/#sv)

    q)` sv `:c:/q,a,`table
    `:c:/q/partofurl/table
    

    Failing that, you can always string and append

    q)`$":c:/q/",string[a],"/table"
    `:c:/q/partofurl/table