# Beginer help, parse and convert a CSV payload

**URL:** <https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320>\
**Category:** General\
**Created:** [20 June 2023 13:44 UTC](https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320 "2023-06-20T13:44:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Faust](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@Faust](https://discourse.nodered.org/u/Faust)\
**Post date:** [20 June 2023 13:44 UTC](https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320/1 "2023-06-20T13:44:30Z")

</div>

Hello all,  
im brand new to Node-Red and I already have a project where im talking to a external device over serial, upon connection, i get the following repeating pattern. each item, separated by comma - is a engine variable with 2 asci digits defining it....im looking for guidance on parse them out to individual integers, by removing the acsi digits after identification.  
any help is appreciated

"TM3,RM0,MP91,VS0,VL121,KY0,FW4,A10,A51,AC0,AD0,AE0,AF0,AG0,X10,XA15,XB0,XC15,XD1,XE1,XF0,XG0,XH0,XX0,ZZ249,TN1~!

TM3,RM0,MP91,VS0,VL121,KY0,FW4,A10,A51,AC0,AD0,AE0,AF0,AG0,X10,XA15,XB0,XC15,XD1,XE1,XF0,XG0,XH0,XX0,ZZ249,TN2~!

TM3,RM0,MP91,VS0,VL121,KY0,FW4,A10,A51,AC0,AD0,AE0,AF0,AG0,X10,XA15,XB0,XC15,XD1,XE1,XF0,XG0,XH0,XX0,ZZ249,TN3~!"

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [20 June 2023 14:13 UTC](https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320/2 "2023-06-20T14:13:42Z")

</div>

This will need JSONata or javascript  
here is a JSONata example

```auto
[{"id":"f7b2df3185229486","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"TM3,RM0,MP91,VS0,VL121,KY0,FW4,A10,A51,AC0,AD0,AE0,AF0,AG0,X10,XA15,XB0,XC15,XD1,XE1,XF0,XG0,XH0,XX0,ZZ249,TN1~!","payloadType":"str","x":110,"y":3840,"wires":[["24d016049605dea6"]]},{"id":"24d016049605dea6","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$substringBefore($$.payload, \"~\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":3780,"wires":[["1091a349318519c3"]]},{"id":"1091a349318519c3","type":"csv","z":"b9860b4b9de8c8da","name":"","sep":",","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":270,"y":3840,"wires":[["e672a35e933f7b16"]]},{"id":"e672a35e933f7b16","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.*.${$substring(0,2):$number( $substring(2))}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":3900,"wires":[["d4e5d4d783d24c39"]]},{"id":"d4e5d4d783d24c39","type":"debug","z":"b9860b4b9de8c8da","name":"debug 315","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":450,"y":3820,"wires":[]}]

```

output

```auto
{"TM":3,"RM":0,"MP":91,"VS":0,"VL":121,"KY":0,"FW":4,"A1":0,"A5":1,"AC":0,"AD":0,"AE":0,"AF":0,"AG":0,"X1":0,"XA":15,"XB":0,"XC":15,"XD":1,"XE":1,"XF":0,"XG":0,"XH":0,"XX":0,"ZZ":249,"TN":1}

```

---

<div class="post-metadata">

**Author:** ![Faust](https://avatars.discourse-cdn.com/v4/letter/f/c89c15/32.png) [@Faust](https://discourse.nodered.org/u/Faust)\
**Post date:** [20 June 2023 14:21 UTC](https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320/3 "2023-06-20T14:21:27Z")

</div>

E1cid, THANK so much! it works perfect! now how do i extract the individual number for 1 item?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [20 June 2023 15:08 UTC](https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320/4 "2023-06-20T15:08:23Z")

</div>

I think you need to watch the [essentials videos](https://m.youtube.com/watch?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6&v=ksGeUD26Mw0&embeds_referring_euri=https%3A%2F%2Fnodered.org%2F&source_ve_path=OTY3MTQ&feature=emb_imp_woyt)  
You may get some benifit and learn how to find paths and target individual properties

`msg.payload.TM` would return 3

---

<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:** [4 July 2023 15:08 UTC](https://discourse.nodered.org/t/beginer-help-parse-and-convert-a-csv-payload/79320/5 "2023-07-04T15:08:43Z")

</div>

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