# Extracting my valuable data from a msg.payload?

**URL:** <https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508>\
**Category:** General\
**Created:** [31 May 2018 15:30 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508 "2018-05-31T15:30:10Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [11 March 2020 19:45 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/21 "2020-03-11T19:45:05Z")

</div>

Hi bakman2, Thank you. I have:  
3 rows retrieved, max rows: 10; local time: Tue Mar 03 18:59:09 UTC 2020  
execution start: 2020-03-03 18:30:22.153 UTC  
{"compile-ms":"9","exec-ms":"94","server-rec'd":"1583260222134","statusDetail":"","status":"DEFAULT","host":"python-85fb5dbf54-t8tbs","total-ms":"107"}

```auto
2020-03-03 18:30:22.153 INFO 451: starting: api replaySession, level: TRACE
2020-03-03 18:30:22.165 DEBUG starting execution
2020-03-03 18:30:22.165 DEBUG replaySession
2020-03-03 18:30:22.166 DEBUG connect-id : r6GJIPvyVflqXpJd
2020-03-03 18:30:22.166 DEBUG sco-id : 11692
2020-03-03 18:30:22.166 DEBUG asset-id : 58754
2020-03-03 18:30:22.235 TRACE PS: SELECT date_start, date_end, attendees_list, transcripts, sco_info, meeting_permissions_list, server FROM session_log WHERE connect_id = ? AND sco_id = ? AND asset_id = ? /* ec81aa30-5d7c-11ea-8ee0-53b4772b249d replaySession */
  -> args: ('r6GJIPvyVflqXpJd', 11692, 58754)
  -> consistency: ONE
2020-03-03 18:30:22.258 DEBUG Failed to find meeting [r6GJIPvyVflqXpJd / 11692 / 58754] in session log
2020-03-03 18:30:22.259 DEBUG 1 datalake keyspace queries
2020-03-03 18:30:22.259 DEBUG executed without exceptions

```

I want to extract the values for connect-id, sco-id and asset-id

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 March 2020 19:53 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/22 "2020-03-11T19:53:05Z")

</div>

Please provide your flow so we can see what you are doing

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [11 March 2020 21:27 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/23 "2020-03-11T21:27:57Z")

</div>

Not sure how you end up with an array if you use a split with tab with the file output you provided.  
but you can try this flow (change the filename ofcourse).

Next time you post output/code, please [use the correct formatting](https://discourse.nodered.org/t/how-to-share-code-or-flow-json) for the forum else it is unreadable (as you can see).

```auto
[{"id":"33dc6e4d.850672","type":"inject","z":"8e22637.94c9ca","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":108,"y":360,"wires":[["32f3e9a7.b92946"]]},{"id":"32f3e9a7.b92946","type":"file in","z":"8e22637.94c9ca","name":"","filename":"/home/administrator/.node-red/test.txt","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":270,"y":408,"wires":[["3a7f5cb9.f176f4"]]},{"id":"3a7f5cb9.f176f4","type":"split","z":"8e22637.94c9ca","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":506,"y":408,"wires":[["dde4ad4e.5f2598"]]},{"id":"dde4ad4e.5f2598","type":"switch","z":"8e22637.94c9ca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"(connect-id|asset-id|sco-id)","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":1,"x":626,"y":408,"wires":[["d1ea3a97.672278"]]},{"id":"2f1ceb90.dd9574","type":"debug","z":"8e22637.94c9ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":866,"y":408,"wires":[]},{"id":"d1ea3a97.672278","type":"function","z":"8e22637.94c9ca","name":"","func":"m = msg.payload\n\ns = m.match(/(connect-id|sco-id|asset-id) : (.+)/); \nkey = s[1]\nval = s[2]\nnode.send({payload:{[key]:val}})","outputs":1,"noerr":0,"x":746,"y":408,"wires":[["2f1ceb90.dd9574"]]}]

```

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [11 March 2020 21:52 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/24 "2020-03-11T21:52:32Z")

</div>

Ok bakman2, Thank you. I know receive the debug output of:  
msg: Object  
{ payload: object,\_msgid: "7667bee4.6c22a"}  
{ payload: object,\_msgid: "e136a3b.a1c366"}  
:  
repeats

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [11 March 2020 21:58 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/25 "2020-03-11T21:58:15Z")

</div>

Because you did not provide complete information.

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [11 March 2020 22:47 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/26 "2020-03-11T22:47:12Z")

</div>

(Hi bakman2, I am attempting to track down the problem. At the output of the switch I received the connect-id, co-id and asset-id as shown below: " 2020-03-03 18:30:22.166 DEBUG connect-id : r6GJIPvyVflqXpJd " At the output of the Function I get: 3/11/2020, 3:40:09 PM[node: 70633e6d.3dcce](http://127.0.0.1:1880/#)msg : Object { payload: object, \_msgid: "48e30cef.3bf5e4" } 0:09 PM[node: c2645ecc.e9233](http://127.0.0.1:1880/#)msg : string[21] "No filename specified")

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [11 March 2020 23:01 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/27 "2020-03-11T23:01:02Z")

</div>

Format your output as i suggested aboved.

And as the output indicates: no filename specified.

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [11 March 2020 23:32 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/28 "2020-03-11T23:32:51Z")

</div>

```auto
[{"id":"7c21d922.203238","type":"inject","z":"dcd1d133.03d3e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":160,"wires":[["5e4025ce.f0019c"]]},{"id":"beaabc21.43a51","type":"file in","z":"dcd1d133.03d3e","name":"","filename":"","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":310,"y":220,"wires":[["90e744a5.479a48","c81e5af4.b68268"]],"info":"msg.filename=\"meeting.log\";\nreturn msg;"},{"id":"90e744a5.479a48","type":"split","z":"dcd1d133.03d3e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":510,"y":220,"wires":[["d6d341f1.6689a","7daaaca7.56f904"]]},{"id":"d6d341f1.6689a","type":"switch","z":"dcd1d133.03d3e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"(connect-id|asset-id|sco-id)","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":1,"x":650,"y":220,"wires":[["2f6f0b14.8ee084","e72bdb94.6f8998"]]},{"id":"70633e6d.3dcce","type":"debug","z":"dcd1d133.03d3e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":690,"y":340,"wires":[]},{"id":"2f6f0b14.8ee084","type":"function","z":"dcd1d133.03d3e","name":"","func":"m = msg.payload\n\ns = m.match(/(connect-id|sco-id|asset-id) : (.+)/); \nkey = s[1]\nval = s[2]\nnode.send({payload:{[key]:val}})\n","outputs":1,"noerr":0,"x":770,"y":260,"wires":[["70633e6d.3dcce","c2645ecc.e9233"]]},{"id":"c81e5af4.b68268","type":"debug","z":"dcd1d133.03d3e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":280,"wires":[]},{"id":"5e4025ce.f0019c","type":"function","z":"dcd1d133.03d3e","name":"Gets Data From Meeting Log","func":"msg.filename=\"meeting.log\";\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":60,"wires":[["beaabc21.43a51"]]},{"id":"7daaaca7.56f904","type":"debug","z":"dcd1d133.03d3e","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":560,"y":140,"wires":[]},{"id":"e72bdb94.6f8998","type":"debug","z":"dcd1d133.03d3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":740,"y":80,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [11 March 2020 23:36 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/29 "2020-03-11T23:36:47Z")

</div>

Hi zenofmud,  
Thanks to bakman2. I was able to progress to get the proper output of the switch with the values for connect-id, sco-id and asset-id. The debug shows that I get two sets of these values and then I get "No Filename specified".

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [11 March 2020 23:43 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/30 "2020-03-11T23:43:17Z")

</div>

Sorry bakman2, i am at a loss for what can be wrong. Are you saying the log I sent you was not formatted properly? What I received from you was a straight drag and copy to node-red.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [11 March 2020 23:45 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/31 "2020-03-11T23:45:17Z")

</div>

@GilHub1 your flow isn't exactly what I had suggested. try this, feed your `file-out` node into this. I've done the bottom flow and left the others for you and you meed to format the end result as you need it.

```auto
[{"id":"2a71e005.30ecc","type":"debug","z":"90560af0.98518","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":200,"wires":[]},{"id":"b4b7cbdc.45d48","type":"split","z":"90560af0.98518","name":"","splt":" : ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":450,"y":320,"wires":[["bd348b2e.ff39d"]]},{"id":"ca19743e.7cce28","type":"switch","z":"90560af0.98518","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"connect-id","vt":"str"},{"t":"cont","v":"sco-id","vt":"str"},{"t":"cont","v":"asset-id","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":270,"y":280,"wires":[["2a71e005.30ecc","ad16c3fc.5bc348"],["c279e347.d2bc48"],["b4b7cbdc.45d48"]]},{"id":"8f4a7dc7.d1fc28","type":"debug","z":"90560af0.98518","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":280,"wires":[]},{"id":"ab22e750.30b708","type":"debug","z":"90560af0.98518","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":400,"wires":[]},{"id":"c279e347.d2bc48","type":"split","z":"90560af0.98518","name":"","splt":" : ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":450,"y":280,"wires":[["8f4a7dc7.d1fc28"]]},{"id":"bd348b2e.ff39d","type":"switch","z":"90560af0.98518","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"asset-id","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":320,"wires":[[],["f60a6251.4b4d98","ab22e750.30b708"]]},{"id":"f60a6251.4b4d98","type":"change","z":"90560af0.98518","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"\"asset-id = \"&payload","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":740,"y":320,"wires":[["ab22e750.30b708"]]},{"id":"ad16c3fc.5bc348","type":"split","z":"90560af0.98518","name":"","splt":" : ","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":450,"y":240,"wires":[["7cad026d.bdcbec"]]},{"id":"7cad026d.bdcbec","type":"debug","z":"90560af0.98518","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":240,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [12 March 2020 00:24 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/32 "2020-03-12T00:24:16Z")

</div>

Thank you very much zenofmud. I did feed this after the split bakman2 gave me. This did isolate the outputs separately down for connect-id, sco-id and asset-id. Very good. Is there a way to just the display the value 1 time only? It seems  
to repeat 2 or 3 times.

I will take this to an output file and to a dashboard for viewing. I think I know how to display that. You have been a great help zenofmud. Thanks again.

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [12 March 2020 17:51 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/33 "2020-03-12T17:51:43Z")

</div>

Thank you Paul. You have been “tremendous help”. I thank you very much!!!

---

<div class="post-metadata">

**Author:** ![GilHub1](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gilhub1/32/20287_2.png) [@GilHub1](https://discourse.nodered.org/u/GilHub1)\
**Post date:** [12 March 2020 17:52 UTC](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508/34 "2020-03-12T17:52:45Z")

</div>

Thank you bakmans2. You were tremendously helpful!!

[Previous page](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508.md?page=1)
