We can use amend functionality to replace the first n items with null value. Additionally, it would be better to use the appropriate null literal for each column based on the type. Something like this would work:
f: {nullDict: "ijfs"!(0Ni;0Nj;0Nf:`); @[x; til y; :; nullDict .Q.ty x]}
This will amend the first y items in the list x. .Q.ty
will get the type for input so that we can get the corresponding value from the dictionary.
You can then use this for a single column, like so:
update mycol: f[mycol;4] from tbl
You can also do this in one go for multiple columns with varying number of items to be replaced using functional form:
![tbl;();0b;`mycol`mycol2!((f[;4];`mycol);(f[;3];`mycol2))]
Do take note that you will need to modify nullDict
with whatever other types you need.
Update: Thanks to Jonathon McMurray for suggesting a better way to build up nullDict
for all primitive types using the below code:
{x!first each x$\:()}.Q.t except " "