Thank everyone for the support!
@Colin, @Steve-Mcl I would like to explain more clearly what I want to do as follows:
I have a CSV file named Summary_File_111222333_20200920.CSV (★), containing a list of files with information such as filepath, size, number of lines, ... of the file:
#filepath,date,size,rows
C:\Temp\Test\P_File_111222333_20200920.CSV,20200920,52,15
C:\Temp\Test\M_File1.CSV,20200920,10,3
C:\Temp\Test\M_File2.CSV,20200920,32,10
C:\Temp\Test\M_File3.CSV,20200920,22,7
I would like to check the information of the file such as whether it exists or not, the size is correct or not, the number of lines of the file is correct. (※)
Therefore, after reading the file (★), I created an array of 5 rows and put in the array-loop
node to check the information (※).
If the information is not correct, it will output the error and break out of the loop, then execute the next node, but I don't know how to break out of array-loop
when there is an error checking the file information.
Since I'm new to node-red, if there is a better way of doing file information check as mentioned above, please tell me!
Any hint will be great.
Thanks in advance.
[{"id":"46ed97cd.a2aa08","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"60bb126a.2d426c","type":"inject","z":"46ed97cd.a2aa08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":130,"y":140,"wires":[["aca44e.f3b90bb"]]},{"id":"aca44e.f3b90bb","type":"file in","z":"46ed97cd.a2aa08","name":"","filename":"/Temp/Test/Summary_File_111222333_20200920.CSV","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":420,"y":140,"wires":[["630281e3.5373"]]},{"id":"cfc6955f.d26048","type":"change","z":"46ed97cd.a2aa08","name":"change","rules":[{"t":"set","p":"array","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1240,"y":240,"wires":[["fd2bd1cb.3939f"]]},{"id":"94a080b8.010bc","type":"split","z":"46ed97cd.a2aa08","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":810,"y":240,"wires":[["6f972bc.379c0d4"]]},{"id":"6f972bc.379c0d4","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$trim(payload)\t","tot":"jsonata"},{"t":"set","p":"cnt","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"cnt","pt":"msg","to":"0","tot":"num"},{"t":"set","p":"cntRowP","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"cntRowP","pt":"msg","to":"0","tot":"num"},{"t":"delete","p":"filenameLen","pt":"msg"},{"t":"set","p":"isInt","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":240,"wires":[["1fb23f26.307a31"]]},{"id":"630281e3.5373","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"filenameLen","pt":"msg","to":"filename","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":200,"wires":[["17089737.a5a959"]]},{"id":"d4ef3b2e.d14ed8","type":"debug","z":"46ed97cd.a2aa08","name":"ログ出力","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1040,"y":160,"wires":[]},{"id":"17089737.a5a959","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"filenameLen","pt":"msg","to":"$replace(filenameLen,/^.*[\\\\\\/]/, '')","tot":"jsonata"},{"t":"set","p":"filenameLen","pt":"msg","to":"$split(filenameLen,'.')[0]","tot":"jsonata"},{"t":"set","p":"filenameLen","pt":"msg","to":"$split(filenameLen,'_')","tot":"jsonata"},{"t":"set","p":"filenameLen","pt":"msg","to":"filenameLen.length","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":200,"wires":[["78582378.07850c"]]},{"id":"78582378.07850c","type":"switch","z":"46ed97cd.a2aa08","name":"","property":"filenameLen","propertyType":"msg","rules":[{"t":"lt","v":"4","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":200,"wires":[["60e8cc20.0fb704"],["94a080b8.010bc"]]},{"id":"60e8cc20.0fb704","type":"change","z":"46ed97cd.a2aa08","name":"エラーメッセージ設定","rules":[{"t":"set","p":"payload","pt":"msg","to":"util.outputLog('fnameChk',msg.filename,'制御')","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":160,"wires":[["d4ef3b2e.d14ed8"]]},{"id":"fd2bd1cb.3939f","type":"array-loop","z":"46ed97cd.a2aa08","name":"array-loop","key":"al1a60a19a718526","keyType":"msg","reset":false,"resetValue":"value-null","array":"array","arrayType":"msg","x":1020,"y":340,"wires":[["715aeff4.6f63a"],["6a153751.7e94e8","d70f6625.d671e8"]]},{"id":"d558d691.61b258","type":"debug","z":"46ed97cd.a2aa08","name":"msg end loop","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1460,"y":340,"wires":[]},{"id":"8da12b4c.16cf08","type":"function","z":"46ed97cd.a2aa08","name":"Func (cnt == 0)","func":"var cnt = flow.get('cnt');\ncnt += 1;\nflow.set('cnt',cnt);\nmsg.cnt = cnt;\n//node.warn('Func (cnt == 0) ' + cnt);\nmsg.payload = 'Func (cnt == 0) ' + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1220,"y":480,"wires":[["4fc0282f.243328"]]},{"id":"4fc0282f.243328","type":"debug","z":"46ed97cd.a2aa08","name":"msg","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1450,"y":480,"wires":[]},{"id":"6a153751.7e94e8","type":"delay","z":"46ed97cd.a2aa08","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":700,"y":480,"wires":[["1a02a480.95513c"]]},{"id":"1a02a480.95513c","type":"switch","z":"46ed97cd.a2aa08","name":"","property":"cnt","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":850,"y":480,"wires":[["c5ef4166.9fcbe","3f30dc84.374e84"],["9718cbce.87a908"]]},{"id":"9718cbce.87a908","type":"function","z":"46ed97cd.a2aa08","name":"Func (cnt != 0)","func":"var cnt = flow.get('cnt');\ncnt += 1;\nflow.set('cnt',cnt);\nmsg.cnt = cnt;\n//node.warn('Func (cnt != 0) ' + cnt);\nmsg.payload = 'Func (cnt != 0) ' + msg.payload;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1020,"y":560,"wires":[["4fc0282f.243328","fd2bd1cb.3939f"]]},{"id":"1fb23f26.307a31","type":"join","z":"46ed97cd.a2aa08","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1110,"y":240,"wires":[["cfc6955f.d26048"]]},{"id":"715aeff4.6f63a","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"End array-loop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":340,"wires":[["d558d691.61b258"]]},{"id":"4417923f.d6febc","type":"debug","z":"46ed97cd.a2aa08","name":"result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":710,"y":900,"wires":[]},{"id":"503af433.cf634c","type":"debug","z":"46ed97cd.a2aa08","name":"ログ出力","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":940,"y":940,"wires":[]},{"id":"cd522055.a9bd4","type":"change","z":"46ed97cd.a2aa08","name":"エラーメッセージ設定","rules":[{"t":"set","p":"payload","pt":"msg","to":"outputLog('formatChk',msg.filename,'制御')","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":940,"wires":[["503af433.cf634c"]]},{"id":"8ce8ae23.7380d","type":"change","z":"46ed97cd.a2aa08","name":"Regex(So nguyen khong am)","rules":[{"t":"set","p":"isInt","pt":"msg","to":"$match(msg.isInt,/^\\d+$/)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":780,"wires":[["5e436a40.9545f4","20ab1e05.dadb62"]]},{"id":"5e436a40.9545f4","type":"function","z":"46ed97cd.a2aa08","name":"2 <= 非負の整数(So nguyen khong am)か確認","func":"/*\n// 整数ではない場合\nif ('undefined' != typeof msg.isInt &&\n 2 <= msg.isInt.match) {\n return [msg,null];\n}\nelse {\n return [null,msg];\n}\n*/\n\nnode.warn('msg.isInt: ' + msg.isInt);\n\nif ('undefined' != typeof msg.isInt &&\n 2 <= payload) {\n msg.infoChk = \"OK\";\n node.warn(\"OK\");\n}\nelse {\n msg.infoChk = \"NG\";\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":450,"y":880,"wires":[["4fc0282f.243328","fd2bd1cb.3939f"]]},{"id":"20ab1e05.dadb62","type":"debug","z":"46ed97cd.a2aa08","name":"cccc","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":600,"y":760,"wires":[]},{"id":"c5ef4166.9fcbe","type":"debug","z":"46ed97cd.a2aa08","name":"aaaa","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"isInt","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":440,"wires":[]},{"id":"3f30dc84.374e84","type":"change","z":"46ed97cd.a2aa08","name":"change","rules":[{"t":"set","p":"isInt","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":640,"wires":[["8ce8ae23.7380d","b2c28e0f.9bbea"]]},{"id":"b2c28e0f.9bbea","type":"debug","z":"46ed97cd.a2aa08","name":"bbbb","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"isInt","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":620,"wires":[]},{"id":"d70f6625.d671e8","type":"debug","z":"46ed97cd.a2aa08","name":"xxx","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1250,"y":400,"wires":[]},{"id":"7ee1d170.04bfe","type":"array-loop","z":"46ed97cd.a2aa08","name":"array-loop","key":"al1a60a19a718526","keyType":"msg","reset":true,"resetValue":"value-empty","array":"array","arrayType":"msg","x":560,"y":1500,"wires":[["8303299.a0144d8"],["dded6341.04cab"]]},{"id":"5f6ec320.8f0f4c","type":"inject","z":"46ed97cd.a2aa08","name":"msg.payload = \"A, B, C, D, E\"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"A, B, C, D, E","payloadType":"str","x":340,"y":1440,"wires":[["e6011028.90ed2"]]},{"id":"ad54dd1a.0a6a9","type":"debug","z":"46ed97cd.a2aa08","name":"out-loop","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":920,"y":1500,"wires":[]},{"id":"e6011028.90ed2","type":"change","z":"46ed97cd.a2aa08","name":"split msg.payload by \", \"","rules":[{"t":"set","p":"array","pt":"msg","to":"$split(msg.payload, ', ')","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":1500,"wires":[["7ee1d170.04bfe"]]},{"id":"1ec40aac.050005","type":"function","z":"46ed97cd.a2aa08","name":"return msg","func":"if (\"C\" === msg.payload) {\n //return '';\n //return false;\n //msg.al1a60a19a718526 = '';\n //return msg;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":650,"y":1640,"wires":[["63580b37.d78394","7ee1d170.04bfe"]]},{"id":"63580b37.d78394","type":"debug","z":"46ed97cd.a2aa08","name":"in-loop","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":1640,"wires":[]},{"id":"dded6341.04cab","type":"delay","z":"46ed97cd.a2aa08","name":"","pauseType":"delay","timeout":"0.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":470,"y":1640,"wires":[["1ec40aac.050005"]]},{"id":"8303299.a0144d8","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"End Loop!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":1500,"wires":[["ad54dd1a.0a6a9"]]},{"id":"46ef2d5d.f0df94","type":"inject","z":"46ed97cd.a2aa08","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":450,"y":1860,"wires":[["99429554.1aef48"]]},{"id":"99429554.1aef48","type":"file in","z":"46ed97cd.a2aa08","name":"","filename":"/Temp/Test/Summary_File_111222333_20200920.CSV","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":740,"y":1860,"wires":[["739a5725.75d548"]]},{"id":"78ac054e.8af95c","type":"change","z":"46ed97cd.a2aa08","name":"change","rules":[{"t":"set","p":"array","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":1920,"wires":[["dcdca1cf.b1c6a"]]},{"id":"739a5725.75d548","type":"split","z":"46ed97cd.a2aa08","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":610,"y":1920,"wires":[["9b014320.d3285"]]},{"id":"9b014320.d3285","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$trim(payload)\t","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":1920,"wires":[["f548407d.4b13b"]]},{"id":"b22ea460.c4a578","type":"array-loop","z":"46ed97cd.a2aa08","name":"array-loop","key":"al1a60a19a718526","keyType":"msg","reset":false,"resetValue":"value-null","array":"array","arrayType":"msg","x":1400,"y":2380,"wires":[["8a9e37c4.216938"],["7bc980a.0caac8"]]},{"id":"afc3003d.eefce","type":"debug","z":"46ed97cd.a2aa08","name":"msg end loop","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1840,"y":2380,"wires":[]},{"id":"b5f4df50.7cf6c","type":"function","z":"46ed97cd.a2aa08","name":"Func (cnt == 0)","func":"var cnt = flow.get('cnt');\ncnt += 1;\nflow.set('cnt',cnt);\nmsg.cnt = cnt;\n//node.warn('Func (cnt == 0) ' + cnt);\nmsg.payload = 'Func (cnt == 0) ' + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1560,"y":2520,"wires":[["b6c2755a.348b88","b22ea460.c4a578"]]},{"id":"b6c2755a.348b88","type":"debug","z":"46ed97cd.a2aa08","name":"msg","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1830,"y":2520,"wires":[]},{"id":"7bc980a.0caac8","type":"delay","z":"46ed97cd.a2aa08","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1080,"y":2520,"wires":[["55e849c9.d80ff8"]]},{"id":"55e849c9.d80ff8","type":"switch","z":"46ed97cd.a2aa08","name":"","property":"cnt","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1230,"y":2520,"wires":[["b5f4df50.7cf6c"],["9e004199.0b728"]]},{"id":"9e004199.0b728","type":"function","z":"46ed97cd.a2aa08","name":"Func (cnt != 0)","func":"var cnt = flow.get('cnt');\ncnt += 1;\nflow.set('cnt',cnt);\nmsg.cnt = cnt;\n//node.warn('Func (cnt != 0) ' + cnt);\nmsg.payload = 'Func (cnt != 0) ' + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1400,"y":2600,"wires":[["b6c2755a.348b88","b22ea460.c4a578"]]},{"id":"f548407d.4b13b","type":"join","z":"46ed97cd.a2aa08","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":950,"y":1920,"wires":[["78ac054e.8af95c"]]},{"id":"8a9e37c4.216938","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"End array-loop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":2380,"wires":[["afc3003d.eefce"]]},{"id":"dcdca1cf.b1c6a","type":"array-loop","z":"46ed97cd.a2aa08","name":"array-loop","key":"al1a60a19a718526","keyType":"msg","reset":true,"resetValue":"value-empty","array":"array","arrayType":"msg","x":660,"y":2020,"wires":[["f771cae4.ef1188"],["ef6bb44f.31a818"]]},{"id":"7100e1c.9778e2","type":"debug","z":"46ed97cd.a2aa08","name":"out-loop","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1020,"y":2020,"wires":[]},{"id":"ba885ac2.cea988","type":"function","z":"46ed97cd.a2aa08","name":"return msg","func":"if (\"C\" === msg.payload) {\n //return '';\n //return false;\n //msg.al1a60a19a718526 = '';\n //return msg;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":750,"y":2160,"wires":[["3f8a9304.e5a7dc","dcdca1cf.b1c6a"]]},{"id":"3f8a9304.e5a7dc","type":"debug","z":"46ed97cd.a2aa08","name":"in-loop","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":2160,"wires":[]},{"id":"f771cae4.ef1188","type":"change","z":"46ed97cd.a2aa08","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"End Loop!","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":2020,"wires":[["7100e1c.9778e2"]]},{"id":"ef6bb44f.31a818","type":"delay","z":"46ed97cd.a2aa08","name":"","pauseType":"delay","timeout":"0.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":570,"y":2160,"wires":[["ba885ac2.cea988"]]}]
http://www.mediafire.com/file/7r39q8v909pmfaz/Test.zip/file