# Working with Comma Separated Data Stream

**URL:** <https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277>\
**Category:** General\
**Created:** [14 August 2018 13:02 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277 "2018-08-14T13:02:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [14 August 2018 13:02 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/1 "2018-08-14T13:02:33Z")

</div>

I am feeding a data stream from a weigh scale. The scale allows me to separate the predefined variable by ",". The data variables are set up in the scale enclosed in \<\>, (i.e. ,,,. ) I am feeding into a Split node and in the debug window I can see each of the variables values. I want to send each variable to a different Gauge in the Dashboard. Any suggestions on how to access these values individually?

Thanks

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 August 2018 13:29 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/2 "2018-08-14T13:29:20Z")

</div>

Do you have an actual example of a full "blob" of data ? Does it come in "lines" ?

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [14 August 2018 13:35 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/3 "2018-08-14T13:35:59Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6e94b77d422448454ff57950c921e8c4cadfa0d3.png)

This is a snip of the command window I have the debug node connected to the output of the TCP node.

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [14 August 2018 13:37 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/4 "2018-08-14T13:37:44Z")

</div>

You can see the 3 variables I am trying to work with. One is the 15 tn/hr, the second is the daily total of about 805 and the third is the master total of about 239924.

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [14 August 2018 14:30 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/5 "2018-08-14T14:30:40Z")

</div>

You said the values were separated by commas -- yet your debug shows each value in its own msg. Is this debug output actually AFTER the split node?

What output options are you using in the `tcp in` node? If you export your flow and include it between two lines with only 3 backtics (`````), then we can import the flow and try in our own environments...

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [14 August 2018 14:45 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/6 "2018-08-14T14:45:08Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/ca90f10613bdb770da9fb8d99adf39a33678fc22.png)

The debug was right after the TCP node. I will attempt to export in a different reply.

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [14 August 2018 14:45 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/7 "2018-08-14T14:45:18Z")

</div>

```auto
[{"id":"8de68d01.1cee9","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"c074a51b.e1cb68","type":"tcp in","z":"8de68d01.1cee9","name":"Secondary Belt Scale","server":"client","host":"10.0.31.113","port":"502","datamode":"stream","datatype":"utf8","newline":"","topic":"Scale","base64":false,"x":180,"y":460,"wires":[["7b063bc4.049154"]],"outputLabels":["Weight"]},{"id":"7b063bc4.049154","type":"split","z":"8de68d01.1cee9","name":"","splt":",","spltType":"str","arraySplt":"5","arraySpltType":"len","stream":true,"addname":"","x":430,"y":460,"wires":[["f8079988.2b9a18"]]},{"id":"f50d455.d5cf5b8","type":"ui_chart","z":"8de68d01.1cee9","name":"","group":"4da77d47.8e8fb4","order":2,"width":"6","height":"6","label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"250","ymax":"400","removeOlder":"20","removeOlderPoints":"","removeOlderUnit":"60","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":870,"y":300,"wires":[[],[]]},{"id":"f8079988.2b9a18","type":"switch","z":"8de68d01.1cee9","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"tn","vt":"str"},{"t":"btwn","v":"0","vt":"num","v2":"3000","v2t":"num"},{"t":"gt","v":"3000","vt":"num"}],"checkall":"true","repair":false,"outputs":3,"x":710,"y":460,"wires":[["d2317820.6cbd28","8dcccb13.4b9968","f50d455.d5cf5b8"],["de5065fe.2c5638","3376c66c.aadb0a"],["fdb8d612.21f338","1679a80f.54c5a8"]]},{"id":"d2317820.6cbd28","type":"debug","z":"8de68d01.1cee9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":890,"y":340,"wires":[]},{"id":"de5065fe.2c5638","type":"debug","z":"8de68d01.1cee9","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":930,"y":460,"wires":[]},{"id":"fdb8d612.21f338","type":"debug","z":"8de68d01.1cee9","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":890,"y":560,"wires":[]},{"id":"1679a80f.54c5a8","type":"ui_gauge","z":"8de68d01.1cee9","name":"","group":"4da77d47.8e8fb4","order":0,"width":0,"height":0,"gtype":"gage","title":"MASTER TOTAL","label":"units","format":"{{value}}","min":0,"max":"3000000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":910,"y":600,"wires":[]},{"id":"3376c66c.aadb0a","type":"ui_gauge","z":"8de68d01.1cee9","name":"","group":"4da77d47.8e8fb4","order":0,"width":0,"height":0,"gtype":"gage","title":"DAILY TOTAL","label":"units","format":"{{value}}","min":0,"max":"4000","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":950,"y":500,"wires":[]},{"id":"8dcccb13.4b9968","type":"ui_gauge","z":"8de68d01.1cee9","name":"","group":"4da77d47.8e8fb4","order":0,"width":0,"height":0,"gtype":"gage","title":"TPH","label":"units","format":"{{value}}","min":0,"max":"600","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":880,"y":400,"wires":[]},{"id":"4da77d47.8e8fb4","type":"ui_group","z":"","name":"Secondary Belt Scale","tab":"d562cb38.4360c8","order":1,"disp":true,"width":"6"},{"id":"d562cb38.4360c8","type":"ui_tab","z":"","name":"Tower","icon":"dashboard","order":2}]

```

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [14 August 2018 14:50 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/8 "2018-08-14T14:50:17Z")

</div>

I was able to configure the switch node to do what I was looking for, of course it will only work once the values are large enough. If I were to reset to zero each day, the second two outputs would be confused.

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [15 August 2018 12:42 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/9 "2018-08-15T12:42:59Z")

</div>

Were you able to run what I sent?

---

<div class="post-metadata">

**Author:** ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)\
**Post date:** [15 August 2018 15:26 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/10 "2018-08-15T15:26:57Z")

</div>

Yes, but as I don't have the raw data stream, it's not easy to test.

It looks like the `tcp in` node is breaking up your data based on some number of bytes or random chunks of time... instead of using "stream" mode, try specifying a "single string" payload, and remove the `split` node. Then we can take a look at the msg.payloads and deal with splitting the values into separate msgs, using the `csv` node (if the order of values is always the same).

---

<div class="post-metadata">

**Author:** ![jfehl](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@jfehl](https://discourse.nodered.org/u/jfehl)\
**Post date:** [15 August 2018 17:24 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/11 "2018-08-15T17:24:39Z")

</div>

When I set the tcp in node to single string, nothing seems to get through to the debug node, so I am not able to get a snap shot of what the string looks like using that method. Any other thoughts?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [15 August 2018 17:58 UTC](https://discourse.nodered.org/t/working-with-comma-separated-data-stream/2277/12 "2018-08-15T17:58:19Z")

</div>

Maybe try a different separator for the line output mode. Maybe \r rather than \n ?
