Search code examples
kdb

Save table to csv file where both file name and table name are variables


If I want to save table table1 to csv file /tmp/table1.csv I can do it with:

`:/tmp/table1.csv 0: csv 0: table1

But what if both file name and table name come from string variables?

fname:"/tmp/table1.csv"
tname: "table1"
/ how do I save table tname to file fname?

Solution

  • This should work:

    hsym[`$fname] 0: csv 0: value `$tname
    

    https://code.kx.com/q/ref/filewords/#hsym

    and valuing a symbol, returns the value of the variable it names.