"The task is to sum the values for each key and print the key with the largest sum." What is the smart way to do this in kdb+? This is my naive, sloppy 15min approach. Warning: Noob. May offend experienced k programmers. k)`t insert+:`k`v!("CI";"\t")0:`:tsvfile k)f:{select (*:k),(sum v) from t where k=x} k)a:f["A"] k)b:f["B"] k)c:f["C"] k)select k from a,b,c where v=(max v)
1#desc sum each group (!/) (" II";"\t") 0: `:tsvfile
Took about 3 seconds, 2.5 of which was reading the fileEDIT:
q)\ts d: (!/) (" II";"\t") 0: `:tsvfile
2489 134218576
q)\ts 1#desc sum each group d
486 253055104