# 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:** 1\
**Showing post:** 23

<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"]]}]

```

---

_[View the full topic](https://discourse.nodered.org/t/extracting-my-valuable-data-from-a-msg-payload/508)._
