Modifying vectors in tables

Hello.

I’m trying to work with vectors on tables/dictionaries and I have a problem.

First I crate simple dictionary with 2 keys:
q)dict: (AAPLL1;AAPLL2)!(2014.09.01 2014.09.02;2014.09.02 2014.09.03)
Next I can modify each element in vector using indexes:

q)dict[AAPLL1;0]: 2014.08.31

All work fine. But when I try to do this with tables a got error `rank:

q)table: ([Symbol:()] L1:();L2:())

q)table upsert (AAPL; (2014.09.01 2014.09.02); (2014.09.02 2014.09.03))

q)table[AAPL;L1;0]

`rank

Also I tried use and got `assign:

q)table[AAPL;L1][0]:2014.08.31

`assign

Both elements in dictionary and in table type of 14h but I can’t understand how to work with it in tables…

table: ([Symbol:`symbol$()] L1:();L2:())

After upsert table already changed types, so it not affect on my problem.

Oh sorry i misread.

When you index into a table you use the column name, but here you have the added complexity of the table being keyed. E.g. tableSymbol would give you the list of symbols (if the table was unkeyed first), but tableAAPL obviously is meaningless because AAPL isn’t a column, it’s a value within the column. So (0!table)`AAPL just gives you an empty list.

Your best bet is an update statement

q)update L1:enlist(2014.08.31 2014.09.02) from table where Symbol=`AAPL

Symbol| L1                    L2

------| -------------------------------------------

AAPL  | 2014.08.31 2014.09.02 2014.09.02 2014.09.03

You can maybe have a cleverer function there that would drop (_) the first element in the list and join on your desired date, depending on what your use case is.

This table will be updated rarely so complexity is not a problem.

Also enlist vector convert it to 0h type and not allow access on vector element.
PS type dict = type table[`AAPL]

There seems to be a restriction on how deep you can index a table.

One way that you can make amendment as such:

.[`table;(`AAPL;`L1);@[;0;:;2014.08.31]]