Struggling with CSV and multiple inputs

[{"id":"e038814.cdfb78","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"42910d99.52e794","type":"delay","z":"e038814.cdfb78","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":550,"y":240,"wires":[["4255d709.d9ac78"]]},{"id":"c0bb3518.927258","type":"delay","z":"e038814.cdfb78","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":550,"y":320,"wires":[["4255d709.d9ac78"]]},{"id":"f66ddce8.98dcb","type":"function","z":"e038814.cdfb78","name":"Add Date And Values","func":"var d = new Date();\n\nvar hh = d.getHours()+2;\nif(hh.toString().length == 1) {\n    var hh = '0'+hh;\n}\nvar mm = d.getMinutes();\nif(mm.toString().length == 1) {\n    var mm = '0'+mm;\n}\nvar ss = d.getSeconds();\nif(ss.toString().length == 1) {\n    var ss = '0'+ss;\n}\n\nvar year = d.getFullYear();\nvar month = d.getMonth()+1; \nif(month.toString().length == 1) {\n    var month = '0'+month;\n}\nvar day = d.getDate();\nif(day.toString().length == 1) {\n    var day = '0'+day;\n}\nvar m ={\"Date\" :year+\"-\"+month+\"-\"+day, \"Time\":hh+\":\"+mm+\":\"+ss, \"Effluent_Out_PH\":msg.Effluent_Out_PH, \"Neutralization_PH\":msg.Neutralization_PH, \"Chrome_Redox_ORP\":msg.Chrome_Redox_ORP, \"Chrome_Redox_PH\":msg.Chrome_Redox_PH};\nconst file = \"/logsheetsEffluent/\"+year+\"-\"+month+\"-\"+day+\".csv\";\nreturn {\n    payload:m,\n    filename: file\n};","outputs":1,"noerr":0,"x":940,"y":400,"wires":[["af50d333.5cf25"]]},{"id":"af50d333.5cf25","type":"csv","z":"e038814.cdfb78","name":"","sep":",","hdrin":true,"hdrout":false,"multi":"one","ret":"\\r\\n","temp":"Date,Time,Value1,Value2","skip":"1","x":1130,"y":400,"wires":[["698b6662.02fea8"]]},{"id":"698b6662.02fea8","type":"file","z":"e038814.cdfb78","name":"Write Date File","filename":"","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"utf8","x":1300,"y":400,"wires":[[]]},{"id":"4255d709.d9ac78","type":"join","z":"e038814.cdfb78","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":750,"y":400,"wires":[["f66ddce8.98dcb"]]},{"id":"f7cdffb8.2ee85","type":"inject","z":"e038814.cdfb78","name":"","topic":"","payload":"7.1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":220,"wires":[["b0cef66d.c9b398"]]},{"id":"71cd0789.391e88","type":"inject","z":"e038814.cdfb78","name":"","topic":"","payload":"7.2","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":300,"wires":[["67cafe8c.26c6a"]]},{"id":"8f6fbe13.4e9ab","type":"inject","z":"e038814.cdfb78","name":"","topic":"","payload":"7.3","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":380,"wires":[["eb69aa78.f02858"]]},{"id":"9753bf0.a684c4","type":"delay","z":"e038814.cdfb78","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":550,"y":400,"wires":[["4255d709.d9ac78"]]},{"id":"14b0a526.4016fb","type":"inject","z":"e038814.cdfb78","name":"","topic":"","payload":"7.4","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":460,"wires":[["8c17c001.dd8d7"]]},{"id":"92c3511e.7abf1","type":"delay","z":"e038814.cdfb78","name":"","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":570,"y":480,"wires":[["4255d709.d9ac78"]]},{"id":"b0cef66d.c9b398","type":"change","z":"e038814.cdfb78","name":"","rules":[{"t":"set","p":"Effluent_Out_PH","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":220,"wires":[["42910d99.52e794"]]},{"id":"67cafe8c.26c6a","type":"change","z":"e038814.cdfb78","name":"","rules":[{"t":"set","p":"Neutralization_PH","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":320,"wires":[["c0bb3518.927258"]]},{"id":"eb69aa78.f02858","type":"change","z":"e038814.cdfb78","name":"","rules":[{"t":"set","p":"Chrome_Redox_ORP","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":400,"wires":[["9753bf0.a684c4"]]},{"id":"8c17c001.dd8d7","type":"change","z":"e038814.cdfb78","name":"","rules":[{"t":"set","p":"Chrome_Redox_PH","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":480,"wires":[["92c3511e.7abf1"]]}]

Please help. This flow does not add any values to the CSV

Is this related to your previous topic ?

Click once on the join node and read the info tab.:

input: To automatically join a sequence of messages, they should all have this property set. The split node generates this property but it can be manually created. It has the following properties:

In your case, you should use a batch node in front on the join node and connect debug nodes to them both to see what is happening.

Sort off yes. I have used your method to inject a file very 00:00 at night
I still cant get it to work. How do i call that in the function node -
image

Nevermind. Found the problem. My CSV node did not have all the columns in it...

Okay now i have managed to let it work.
But, lets say 7.1 inject 2 times and 7.2 inject 2 times. Thats 4 msgs at the join node so it send it through to the function node which writes that 2 values but leave the other two blank. is there a way to code it so that the other two writes zero when it receives nothing or error in that row

This you cannot solve with the join/batch node, this is about your input. (well maybe you could, but it is error prone)
How is your input processed, do you (want to) receive each a value every 5 seconds ?

I would suggest to set it up in a different way:

Date,Time,Measurement,Value
2020-04-27,00:10:03,Effluent_Out_PH,7.1
2020-04-27,00:10:04,Chrome_Redox_ORP,7.2
...

The input comes from a PLC node which i will set to emit continuously. So i think the join with the delay should work.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.