Home › Forums › kdb+ › Unpack nested column in table › Re: Unpack nested column in table
-
A generalized solution that doesn’t use hardcoded column names (provided as input) or assume the the cells in the nested column having the same length (padded with null for those with shorter length).
unpack:{[t;c] maxLen:max count each t[c]; newCols:`$string[c] ,/: string 1+til maxLen; // concatenate the parts other than the specified column, with the unpacked parts //(x;::;y) is the parsed form of x[;y] ![t; (); 0b; enlist c] ,' ?[t; (); 0b; newCols!{(x;::;y)}'[c;til maxLen]] }