You can use the msg.columns and split it to to count the length, or pop() the last element for the name.
e.g.
[{"id":"b3f55db2ad2b7341","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":1820,"wires":[["dee2d518076c0f3b"]]},{"id":"dee2d518076c0f3b","type":"template","z":"65617ffeb779f51c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"1,2\n3,4\n","output":"str","x":320,"y":1820,"wires":[["c7e5c56d2b1fa550"]]},{"id":"c7e5c56d2b1fa550","type":"csv","z":"65617ffeb779f51c","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":470,"y":1820,"wires":[["db78d29828eedd96"]]},{"id":"db78d29828eedd96","type":"function","z":"65617ffeb779f51c","name":"function 22","func":"msg.payload.last = msg.columns.split(\",\").pop()\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":550,"y":1880,"wires":[["5f7fa29e890ddf50"]]},{"id":"5f7fa29e890ddf50","type":"debug","z":"65617ffeb779f51c","name":"debug 242","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":1820,"wires":[]}]
msg.payload.last = msg.columns.split(",").pop()