I have a text file that contains an empty line like this:
a
b
c
d
e
f
When reading the file I want the resulting array to get rid of the empty values using the $filter
of the change
node.
https://docs.jsonata.org/higher-order-functions#filter
..but not working, i don't know what went wrong?
Please tell me. Thanks!
[{"id":"8d9ec817.efd0b8","type":"inject","z":"f1e299b0.7d26b8","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":1600,"wires":[["8926455e.3b12c8"]]},{"id":"8926455e.3b12c8","type":"file in","z":"f1e299b0.7d26b8","name":"","filename":"/Temp/File1.txt","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":380,"y":1600,"wires":[["b5a982d9.951d2"]]},{"id":"1fe3fff6.16cab","type":"debug","z":"f1e299b0.7d26b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":1600,"wires":[]},{"id":"b5a982d9.951d2","type":"change","z":"f1e299b0.7d26b8","name":"$split(msg.payload,'\\n')","rules":[{"t":"set","p":"srcArray","pt":"msg","to":"$split(msg.payload,'\\n')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":1600,"wires":[["c2c03026.b1631"]]},{"id":"c2c03026.b1631","type":"change","z":"f1e299b0.7d26b8","name":"$filter","rules":[{"t":"set","p":"destArray","pt":"msg","to":"$filter(srcArray, function($v) {\t 0 < $length($v)\t})","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":1600,"wires":[["1fe3fff6.16cab"]]}]