Given the table defined above you could make use of value
to extract the data from the table without column headers:
q)value each table
"source_one" "addr1:port1:id1:pass1" "table_one" "tableName1" "syms_one" "SYM1 SYM2 SYM3"
"source_two" "addr2:port2:id2:pass2" "table_two" "tableName2" "syms_two" "SYM21 SYM22 SYM23"
From here you can raze
the ouptut to give a single list which can then be cut
into pairs (2):
q)2 cut raze value each table
"source_one" "addr1:port1:id1:pass1"
"table_one" "tableName1"
"syms_one" "SYM1 SYM2 SYM3"
...
Finally using flip
puts it into a format that can be used to make a dictionary using !
:
(!). flip 2 cut raze value each table
"source_one"| "addr1:port1:id1:pass1"
"table_one" | "tableName1"
"syms_one" | "SYM1 SYM2 SYM3"
"source_two"| "addr2:port2:id2:pass2"
"table_two" | "tableName2"
"syms_two" | "SYM21 SYM22 SYM23"
If the keys need to be symbols then you can make use of @
apply to convert them before creating the dictionary:
(!). @[;0;`$]flip 2 cut raze value each table
A better approach may be to create the table without the use of enlist
and dropping the column headers with 1_
, before making use of the same method to create the dictionary:
(!). flip raze cut[2]each 1_flip("******";",") 0: `:source.csv