Add Single String to msg.payload so csv output prints as title of messages?

ah i see, thats fair enough, to be honest i do infact want a tab before the first message of the readings to i've added it. i've done some jiggery pokery and using your flow to simulate it i've managed to get the values out as numbers with board names as CSV headers
for your curiosity this is how i jigged yours:

[{"id":"7bfc1276c35b6509","type":"tab","label":"CSV","disabled":false,"info":"","env":[]},{"id":"03c9c0616c672829","type":"inject","z":"7bfc1276c35b6509","name":"Start Batch","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":220,"wires":[["5e9222632ba1334e"]]},{"id":"4e5849be7752ca47","type":"comment","z":"7bfc1276c35b6509","name":"Replace with Start Button Pressed event","info":"","x":200,"y":180,"wires":[]},{"id":"ce9e5217f32843f8","type":"inject","z":"7bfc1276c35b6509","name":"Serial Row","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1\t2\t3\t4","payloadType":"str","x":120,"y":360,"wires":[["b3d3c7247052f86b"]]},{"id":"ce54001e098a57e6","type":"comment","z":"7bfc1276c35b6509","name":"Replace with serial input","info":"","x":150,"y":320,"wires":[]},{"id":"3ccc0f7cc0b78546","type":"change","z":"7bfc1276c35b6509","name":"","rules":[{"t":"set","p":"started","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":220,"wires":[["d492314b5a670940"]]},{"id":"5e9222632ba1334e","type":"switch","z":"7bfc1276c35b6509","name":"Not Started?","property":"started","propertyType":"flow","rules":[{"t":"false"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":220,"wires":[["3ccc0f7cc0b78546"],["3ccc0f7cc0b78546"]]},{"id":"795960c49f6c5518","type":"comment","z":"7bfc1276c35b6509","name":"Replace with Stop Button Pressed event","info":"","x":200,"y":460,"wires":[]},{"id":"ffcdcd5d59e8b750","type":"inject","z":"7bfc1276c35b6509","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":500,"wires":[["81c2379d0ea67134"]]},{"id":"81c2379d0ea67134","type":"change","z":"7bfc1276c35b6509","name":"","rules":[{"t":"set","p":"started","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":500,"wires":[[]]},{"id":"bf3167a5aa971165","type":"csv","z":"7bfc1276c35b6509","name":"","sep":"\\t","hdrin":true,"hdrout":"all","multi":"one","ret":"\\n","temp":"    ,Board 1, Board 2, Board 3, Board 4,","skip":"0","strings":true,"include_empty_strings":true,"include_null_values":true,"x":590,"y":640,"wires":[["be18bb8c452ef282","b17e46e1c13e1ab3"]]},{"id":"be18bb8c452ef282","type":"file","z":"7bfc1276c35b6509","name":"","filename":"C:\\Users\\223131446\\documents\\CSV.xls","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"false","encoding":"none","x":910,"y":640,"wires":[[]]},{"id":"368c0794da18eb4c","type":"inject","z":"7bfc1276c35b6509","name":"On Start Up","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":100,"wires":[["2afa3d1da87c5f3a"]]},{"id":"736f27152da7eb26","type":"link in","z":"7bfc1276c35b6509","name":"link in 1","links":["c847e5c58cde0c9b"],"x":65,"y":640,"wires":[["49412ebf550e8a93"]]},{"id":"fcab9a3611ea143b","type":"link out","z":"7bfc1276c35b6509","name":"link out 1","mode":"link","links":[],"x":635,"y":100,"wires":[]},{"id":"d72516572e8c2694","type":"link out","z":"7bfc1276c35b6509","name":"link out 2","mode":"link","links":[],"x":1115,"y":220,"wires":[]},{"id":"f0e01029efaf89fb","type":"comment","z":"7bfc1276c35b6509","name":"Sets the top level header when deployed","info":"","x":200,"y":60,"wires":[]},{"id":"d492314b5a670940","type":"function","z":"7bfc1276c35b6509","name":"Set Batch Header","func":"msg.payload = `${new Date()}` + '\\n'\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":850,"y":200,"wires":[["d72516572e8c2694","be18bb8c452ef282"]]},{"id":"c847e5c58cde0c9b","type":"link out","z":"7bfc1276c35b6509","name":"link out 3","mode":"link","links":["736f27152da7eb26"],"x":815,"y":360,"wires":[]},{"id":"c0899d814360eab8","type":"comment","z":"7bfc1276c35b6509","name":"Sink to CSV","info":"","x":110,"y":600,"wires":[]},{"id":"2afa3d1da87c5f3a","type":"function","z":"7bfc1276c35b6509","name":"Set File Header","func":"msg.payload = '2kV Test Readings' + '\\n'\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":100,"wires":[["fcab9a3611ea143b","be18bb8c452ef282"]]},{"id":"06effc064c18e04b","type":"function","z":"7bfc1276c35b6509","name":"Pad Column","func":"msg.payload = '\t' + msg.payload\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":360,"wires":[["c847e5c58cde0c9b"]]},{"id":"49412ebf550e8a93","type":"function","z":"7bfc1276c35b6509","name":"Split to Columns","func":"msg.payload = msg.payload.split('\t')\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":640,"wires":[["bf3167a5aa971165"]]},{"id":"b3d3c7247052f86b","type":"switch","z":"7bfc1276c35b6509","name":"Started?","property":"started","propertyType":"flow","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":440,"y":360,"wires":[["06effc064c18e04b"]]},{"id":"b17e46e1c13e1ab3","type":"debug","z":"7bfc1276c35b6509","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":520,"wires":[]}]

and it's allowed me to present the data in excel like this: which is near spot on!!!

with that i should be able to integrate it to the full flow that is taking the serial data :slight_smile: thanks again for your invaluable help marcus

1 Like

ah @marcus-j-davies i've attempted to integrate it to my automatic dataflow, but it's misbehaving because i want the time stamp not just once per start but once per reading. and CSV node doesn't like it for some reason

Try replacing the code in the Pad Column block with the below.

msg.payload = `${new Date()}\n	${msg.payload}`
return msg;

yeah that's basically what i was doing with this:

var timestamp = new Date().toString()+'\n';
msg.payload = timestamp +'\t '+ msg.payload;
return msg;

But this ends up being the output to excel:

(i have also compared my pad column method to yours and i get same result btw)

currently trying to figure out a way to get the items in column to to effectively drop one row down... tricky stuff

@marcus-j-davies GOOD NEWS! i figured out how to shift it all down :slight_smile: by duplicating my time sticker and placing the node AFTER the CSV node i now get this:

1 Like

Sorry - Got called away.

Nice work!!

1 Like

no worries, thank you again for your tutelage :smiley:

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