How to uppercase the first letter of a string in kdb+

One of the most common operations with strings is to make the string capitalized: uppercase its first letter, and leave the rest of the string as-is.

The best way to do this is through a combination of two functions. One uppercases the first letter (upper function), and the second slices the string and returns it starting from the second character (function cut, drop).

yourTable:update `${(upper x[0]),x[1]} each {0 1_string x} each yourColumn from yourTable;


An example of use is the following code where we are generating one hundred of dummy lines. Note that we are using a symbol column and we convert the symbols to strings in the process.

yourTable:([]x:100?.z.t;sym:`column);
yourTable:update `${(upper x[0]),x[1]} each {0 1_string x} each sym from yourTable;

We get this result.

Leave a Reply

Your email address will not be published. Required fields are marked *