How to create a table with column names using temporal values

Good day everyone who’s reading, 

Would someone be so kind and advise on how to create a table with column names of temporal data? 

I have a table with time column containing time stamps, but I would like to create another table which will have separate columns “named” using each of the time stamps from the previously mentioned table:

A:( 10:00:00.001 10:00:00.002 etc; px: SomeKindOfPriceList)

Tried all kind of casting but still it would not let me use the timestamp as a name for each column. I get quite close by creating a list and then trying to flip it but I get the “NYI” - the not yet implement error. 

Please help if you have a minute or tow to spare, 

Regards, 

VA

Hey VA,

For a table like this:

q)t:(time:10:00:00 10:00:01;px:1 2)

q)t

time px

-----------

10:00:00 1

10:00:01 2

You’re right, simply trying to flip a dict of times to prices results in 'nyi:

q)flip enlist each t.time!t.px

'nyi

But if you cast the times to symbols it will work:

q)r:flip enlist each (`$string t.time)!t.px

q)r

10:00:00 10:00:01

-----------------

1 2

However, having such unusual values as column headers is probably not the best idea.  For example it will break some q-sql syntax:

q)select 10:00:00 from r

'rank

Hope that helps anyway!

All the best,

Matt Doherty

On Monday, January 9, 2017 at 4:40:24 PM UTC-5, VA wrote:

 I would like to create another table which will have separate columns “named” using each of the time stamps from the previously mentioned table:

A:( 10:00:00.001 10:00:00.002 etc; px: SomeKindOfPriceList)

q)A:(a:10:00:00.001 10:00:00.002)

q)flip(exec `$string a from A)!()

10:00:00.001 10:00:00.002

------------------------- 

This will do what you want, but I would strongly recommend making column names valid identifiers.  For example,

q)flip (exec `${“x”,ssr[x;“[:.]”;“_”]}each string a from A)!()

x10_00_00_001 x10_00_00_002


Oh dear.. I just went back to the forum and realised that I have never posted a reply. I never actually clicked on post reply button. So sorry. Thank you so much for all your replies. It worked great! and pivot tables rule!