KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Removing quotation from a column name Reply To: Removing quotation from a column name

  • unterrainer_ale

    Member
    November 19, 2024 at 8:37 pm

    The syntax for xcols is `newName xcol tableName , because it looks like you are sending the query over a handle you have to do either h_feed “`newName xcol tableName” or h_feed(xcol;`newName;tableName)

    Note that xcol renames the first column to the first symbol. so if your update_date is at position n you need n-1 column names before on the left side. Not sure if that makes sense but you can read the documentation about xcol here https://code.kx.com/q/ref/cols/#xcol

    You can also use .Q.id to sanitise your column names

    (base) alexanderunterrainer@Alexanders-Laptop:~|⇒ cat table.csv

    “”update_date*””,goodName

    1,2

    3,4

    5,6

    q)t:(“II”;enlist csv) 0:`table.csv

    q)t

    “update_date*” goodName

    ———————–

    1 2

    3 4

    5 6

    q).Q.id t

    update_date goodName

    ——————–

    1 2

    3 4

    5 6

    or using xcol

    q)`newGoodName xcol t

    newGoodName goodName

    ——————–

    1 2

    3 4

    5 6