0

I have tried to do the following in several different ways but haven't succeeded so far.

I have a list of tables that goes like this:

.rsk.list
extract1.csv | +`date`code etc.
...

I can call the table like this .rsk.list[`extract1.csv] Or I can raze .rsk.list to get a table of all extracts. Except it's not really a table (type 0b)

My goal is to copy some extracts, let's say toload:`extract1.csv`extract5.csv to a second table, let's call it .rsk.list2

I have tried many variations of this

tmp:{.rsk.risk[x]} each toload    \which works
{.rsk.list2[x]:y}[each toload;each tmp}   \which does not

If you have any idea how to make the above work or how to cast raze .rsk.list to a table, I'll be forever grateful.

Will Da Silva
  • 6,386
  • 2
  • 27
  • 52
Victor Gl
  • 81
  • 1
  • 8

1 Answers1

2

In order to join on extract1.csv and extract5.csv effectively it would help to see what they look like.

When you raze a list of non-conformant tables it will generate a mixed list (type 0) of dictionaries e.g.:

q).rsk.list:`1.csv`2.csv!(([]a:`a`b`c;b:til 3);([]c:`d`e`f;d:2*til 3))
q).rsk.list[`1.csv]
a b
---
a 0
b 1
c 2
q).rsk.list[`2.csv]
c d
---
d 0
e 2
f 4
q)raze .rsk.list
`a`b!(`a;0)
`a`b!(`b;1)
`a`b!(`c;2)
`c`d!(`d;0)
`c`d!(`e;2)
`c`d!(`f;4)

q)type raze .rsk.list
0h

One method is using uj and over(/) but it depends on your usecase whether this achieves the desired result:

q)(uj/) .rsk.list[`1.csv`2.csv]
a b c d
-------
a 0
b 1
c 2
    d 0
    e 2
    f 4

This is a table but not necessarily a useful one

Matt Moore
  • 2,705
  • 6
  • 13
  • Thanks a lot! {.rsk.list2[x]:y}[each toload; each tmp] was not working so I ended up doing something like this {.rsk.list2[exec first name from x]:x}[each tmp] – Victor Gl May 07 '21 at 21:02