# Read from text file?

**URL:** <https://discourse.nodered.org/t/read-from-text-file/25963>\
**Category:** General\
**Created:** [2 May 2020 22:45 UTC](https://discourse.nodered.org/t/read-from-text-file/25963 "2020-05-02T22:45:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![asdf123](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@asdf123](https://discourse.nodered.org/u/asdf123)\
**Post date:** [2 May 2020 22:45 UTC](https://discourse.nodered.org/t/read-from-text-file/25963/1 "2020-05-02T22:45:16Z")

</div>

Hi,

I'd like to ask for help on how to extract certain lines from a txt file.  
The text file is like:  
"attackComplexity" : "LOW",\r\n "privilegesRequired" : "NONE",\r\n "userInteraction" : "NONE",\r\n "scope" : "UNCHANGED",\r\n "confidentialityImpact" : "HIGH",\r\n "integrityImpact" : "HIGH",\r\n "availabilityImpact" : "HIGH",\r\n "baseScore" : 9.8,\r\n "baseSeverity" : "CRITICAL"\r\n },\r\n "exploitabilityScore" : 3.9,\r\n "impactScore" : 5.9\r\n },\r\n "baseMetricV2" : {\r\n "cvssV2" : {\r\n "version" : "2.0",\r\n "vectorString" : "AV:N/AC:L/Au:N/C:P/I:P/A:P",\r\n "accessVector" : "NETWORK",\r\n "accessComplexity" : "LOW",\r\n "authentication" : "NONE",\r\n "confidentialityImpact" : "PARTIAL",\r\n "integrityImpact" : "PARTIAL",\r\n "availabilityImpact" : "PARTIAL",\r\n "baseScore" : 7.5\r\n },\r\n "severity" : "HIGH",\r\n "exploitabilityScore" : 10.0,\r\n "impactScore" : 6.4,\r\n "acInsufInfo" : false,\r\n "obtainAllPrivilege" : false,\r\n "obtainUserPrivilege"

And i like to get those rows which after the title like attackComplexity (LOW), userInteraction (NONE), and so on.  
Thanks.

---

<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:** [2 May 2020 23:03 UTC](https://discourse.nodered.org/t/read-from-text-file/25963/2 "2020-05-02T23:03:07Z")

</div>

As it's pretty much JSON minus the starting`{` and ending `}` I'd probably ....

- add the curly brackets
- Send it through a JSON node
- Access any property I need by member (e.g. `msg.payload.obtainAllPrivilege`)

---

<div class="post-metadata">

**Author:** ![asdf123](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@asdf123](https://discourse.nodered.org/u/asdf123)\
**Post date:** [2 May 2020 23:21 UTC](https://discourse.nodered.org/t/read-from-text-file/25963/3 "2020-05-02T23:21:21Z")

</div>

Okay, and how can i do all of that?

---

<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:** [2 May 2020 23:29 UTC](https://discourse.nodered.org/t/read-from-text-file/25963/4 "2020-05-02T23:29:44Z")

</div>

File in node - function node - JSON node - debug node.

Function node code ....

```auto
msg.payload = "{" + msg.payload + "}";
return msg;

```

Ps, read the docs, search the forum, watch some videos. There is some amazing info available.

---

<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:** [1 July 2020 23:29 UTC](https://discourse.nodered.org/t/read-from-text-file/25963/5 "2020-07-01T23:29:54Z")

</div>

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