I would like to get the line number of a CSV file in function
node.
I tried to execute the code below in function
node but couldn't get the count value.
Do not know where the cause is?
[{"id":"61e780fd.ae573","type":"function","z":"e62775a6.462558","name":"","func":"var fs = global.get('fs');\nvar readline = global.get(\"readline\");\nvar filepath = \"/Temp/TestFile.CSV\";\n\n// line number of a CSV file\nvar count = 0;\n\nvar rd = readline.createInterface({\n input: fs.createReadStream(filepath),\n crlfDelay: Infinity\n});\n\nrd.on('line', function(line) {\n count++;\n node.warn(\"count Inside: \" + count);\n});\n\nnode.warn(\"■ ■ count OutSide: \" + count);\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":1120,"wires":[["340867e7.bdde68"]]},{"id":"340867e7.bdde68","type":"debug","z":"e62775a6.462558","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":1120,"wires":[]},{"id":"9aa20a11.74a0a8","type":"inject","z":"e62775a6.462558","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":220,"y":1120,"wires":[["61e780fd.ae573"]]}]