# Split data stream

**URL:** <https://discourse.nodered.org/t/split-data-stream/35797>\
**Category:** General\
**Created:** [12 November 2020 11:05 UTC](https://discourse.nodered.org/t/split-data-stream/35797 "2020-11-12T11:05:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nuiler](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuiler](https://discourse.nodered.org/u/nuiler)\
**Post date:** [12 November 2020 11:05 UTC](https://discourse.nodered.org/t/split-data-stream/35797/1 "2020-11-12T11:05:29Z")

</div>

I want to split the data stream I receive into different variables. The values are separated by a comma.

Enclosed a copy of the data stream

50,57,51,54,0,1,2,2013,2024,32,40561,0,587,0,0,61536,4000,8675,0,1392,45600,3485,52935

Enclosed the node with which I want to read a PV memory via Modbus TCP

```auto
[{"id":"a415dce4.a57f","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"f3d27682.364cb8","type":"modbustcp-read","z":"a415dce4.a57f","name":"PV-Speicher alle Werte","topic":"pv-speicher","dataType":"InputRegister","adr":"1059","quantity":"23","rate":"1","rateUnit":"s","server":"aa8af165.8798e","ieeeType":"off","ieeeBE":true,"x":130,"y":120,"wires":[["a4e2a17d.d81f2"]]},{"id":"a4e2a17d.d81f2","type":"json","z":"a415dce4.a57f","name":"","property":"payload","action":"","pretty":false,"x":130,"y":220,"wires":[["846aa32f.9c4a4"]]},{"id":"846aa32f.9c4a4","type":"change","z":"a415dce4.a57f","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"[","fromt":"str","to":"","tot":"str"},{"t":"change","p":"payload","pt":"msg","from":"]","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":220,"wires":[["826a8ee7.982ef"]]},{"id":"826a8ee7.982ef","type":"debug","z":"a415dce4.a57f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":160,"wires":[]},{"id":"aa8af165.8798e","type":"modbustcp-server","name":"PV-Speicher","host":"192.168.178.11","port":"502","unit_id":"1","reconnecttimeout":"60"}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 November 2020 13:31 UTC](https://discourse.nodered.org/t/split-data-stream/35797/2 "2020-11-12T13:31:30Z")

</div>

Please see this post for how to format a flow so that it can be imported. [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

Please post a screenshot of the output from the modbus node in a debug node so we can see exactly what we are dealing with.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 November 2020 15:00 UTC](https://discourse.nodered.org/t/split-data-stream/35797/3 "2020-11-12T15:00:24Z")

</div>

Look at the [buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser) node. It is ideal for taking a buffer and turning it into a nice key/value object.

---

<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:** [12 November 2020 16:12 UTC](https://discourse.nodered.org/t/split-data-stream/35797/4 "2020-11-12T16:12:26Z")

</div>

or if it is really just a string then maybe the CSV node

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [12 November 2020 17:21 UTC](https://discourse.nodered.org/t/split-data-stream/35797/5 "2020-11-12T17:21:57Z")

</div>

I suspect as the OP mentions Modbus TCP and "values are separated by a comma" is more so an array data items that need coercing into nice values.

I could be wrong - it happens 😃

---

<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:** [12 November 2020 17:47 UTC](https://discourse.nodered.org/t/split-data-stream/35797/6 "2020-11-12T17:47:57Z")

</div>

Indeed - but when they include more than just bytes it looks less like a buffer. so ... who knows... (well hopefully OP 😉

---

<div class="post-metadata">

**Author:** ![nuiler](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@nuiler](https://discourse.nodered.org/u/nuiler)\
**Post date:** [13 November 2020 12:08 UTC](https://discourse.nodered.org/t/split-data-stream/35797/7 "2020-11-13T12:08:50Z")

</div>

I am now getting values. How can i convert the value to sint16 now?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 November 2020 12:49 UTC](https://discourse.nodered.org/t/split-data-stream/35797/8 "2020-11-13T12:49:20Z")

</div>

> [@nuiler](#):
>
> How can i convert the value to sint16 now

did you look at this?

> [@Steve-Mcl](#):
>
> Look at the [buffer-parser](https://flows.nodered.org/node/node-red-contrib-buffer-parser) node

[This recent post](https://discourse.nodered.org/t/modbus-buffer-parser-32-bit/35815/2) might help

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 January 2021 12:49 UTC](https://discourse.nodered.org/t/split-data-stream/35797/9 "2021-01-12T12:49:21Z")

</div>

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