Search code examples
castingkdb

KDB+ Cast symbol to char


I have a table containing file paths in symbol format as follows:

t : ([]date:"d"$til 5; filepath:`aaa.pdf`bbb.pdf`ccc.pdf`ddd.pdf`eee.pdf)

date       filepath
-------------------
2000.01.01 aaa.pdf 
2000.01.02 bbb.pdf 
2000.01.03 ccc.pdf 
2000.01.04 ddd.pdf 
2000.01.05 eee.pdf 

I want to convert column filepath to char, but the following are not working:

update "c"$filepath from t

update {"c"$x} each filepath from t

Solution

  • Use the string key word.

    q)update string filepath from t
    date       filepath 
    --------------------
    2000.01.01 "aaa.pdf"
    2000.01.02 "bbb.pdf"
    2000.01.03 "ccc.pdf"
    2000.01.04 "ddd.pdf"
    2000.01.05 "eee.pdf"