# Is the result of reading one line of the file a string?

**URL:** <https://discourse.nodered.org/t/is-the-result-of-reading-one-line-of-the-file-a-string/32861>\
**Category:** General\
**Created:** [14 September 2020 09:52 UTC](https://discourse.nodered.org/t/is-the-result-of-reading-one-line-of-the-file-a-string/32861 "2020-09-14T09:52:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [14 September 2020 09:52 UTC](https://discourse.nodered.org/t/is-the-result-of-reading-one-line-of-the-file-a-string/32861/1 "2020-09-14T09:52:46Z")

</div>

I used `file in` node to read the **ini** file, but comparing the value of the readable line is not correct

```auto
var val1 = "[PATH]".localeCompare(msg.payload); // val1 = -1
var val2 = "[PATH]" === msg.payload; // val2 = false

```

 ![file-in-node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/d/ad27d1beaab737dae333ebaa92e16c986537710e.png)

```auto
[{"id":"f822faf5.cc3ea8","type":"file in","z":"aa40b590.ff1888","name":"","filename":"/Temp/Test.ini","format":"lines","chunk":false,"sendError":false,"encoding":"Shift_JIS","x":1500,"y":2420,"wires":[["d7be30e5.716ed"]]},{"id":"9cab729f.2d89f","type":"inject","z":"aa40b590.ff1888","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":1330,"y":2360,"wires":[["f822faf5.cc3ea8"]]},{"id":"d7be30e5.716ed","type":"debug","z":"aa40b590.ff1888","name":"result","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1630,"y":2500,"wires":[]}]

```

How the comparison is please just help me!  
Thanks.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [14 September 2020 10:10 UTC](https://discourse.nodered.org/t/is-the-result-of-reading-one-line-of-the-file-a-string/32861/2 "2020-09-14T10:10:42Z")

</div>

Trying comparing against `msg.payload.trim()` - that will remove the extra whitespace (my guess, a `\r` as you're on windows) that you can see in the Debug side view as.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [14 September 2020 21:37 UTC](https://discourse.nodered.org/t/is-the-result-of-reading-one-line-of-the-file-a-string/32861/3 "2020-09-14T21:37:13Z")

</div>

@knolleary Thank you very much!^^

---

<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:** [28 September 2020 21:37 UTC](https://discourse.nodered.org/t/is-the-result-of-reading-one-line-of-the-file-a-string/32861/4 "2020-09-28T21:37:25Z")

</div>

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