How to rename the column name of a table according to a variable

1,644 views
Skip to first unread message

Wind

unread,
Mar 5, 2009, 2:39:29 AM3/5/09
to Kdb+ Personal Developers
We could change col names with xcol:
q)cols b
`sym`date`close
q)b:`sym`date`ibm.close xcol b
q)cols b
`sym`date`ibm.close

The questions are as following:
1. could we change the col names according to a variable? such as :
q)x:`GOOG
q)`sym`date`$(string x) xcol b
'nyi

2. whether xcol is the efficient method changing name of columns.

Thanks.

Charlie Skelton,Kx

unread,
Mar 5, 2009, 3:18:07 AM3/5/09
to personal...@googlegroups.com
yes

q)(`sym`date,`$string x) xcol b

xcol is very efficient

Attila Vrabecz

unread,
Mar 5, 2009, 3:35:13 AM3/5/09
to personal...@googlegroups.com
(`sym`date,x) xcol b
is enough if x is already a symbol
Attila

Wind

unread,
Mar 5, 2009, 4:55:11 AM3/5/09
to Kdb+ Personal Developers
Great. That works well.
Thanks Attila

Wind

On Mar 5, 4:35 pm, Attila Vrabecz <attila.vrab...@gmail.com> wrote:
> (`sym`date,x) xcol b
> is enough if x is already a symbol
>   Attila
>
> On Thu, Mar 5, 2009 at 8:18 AM, Charlie Skelton,Kx <char...@kx.com> wrote:
> > yes
> > q)(`sym`date,`$string x) xcol b
>
> > xcol is very efficient
Reply all
Reply to author
Forward
0 new messages