# String with 2 points from CSV to number

**URL:** <https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292>\
**Category:** General\
**Created:** [8 March 2023 12:06 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292 "2023-03-08T12:06:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [8 March 2023 12:06 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/1 "2023-03-08T12:06:59Z")

</div>

Good morning,

I have a problem with one value from csv, when i get this value i recive a string with 2 points (Ej: 1.480.200) and cant convert into a number.

I need convert this string in a number and divide this value /10000, but i cant divide this as string.

Someone know how to do this?

Thanks.

---

<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:** [8 March 2023 12:19 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/2 "2023-03-08T12:19:13Z")

</div>

You can replace the `.` with `""` then do the maths.  
here is an example using JSONate

```auto
[{"id":"752f9e00aec8eaa2","type":"debug","z":"65617ffeb779f51c","name":"debug 237","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":380,"wires":[]},{"id":"df8cf0d9b3c78ec7","type":"change","z":"65617ffeb779f51c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload ~> |$|{\"col3\": $number( $replace( $.col3,\".\", \"\") ) / 100000}|","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":280,"wires":[["752f9e00aec8eaa2"]]},{"id":"004a11f6ac394aef","type":"csv","z":"65617ffeb779f51c","name":"","sep":",","hdrin":"","hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":430,"y":200,"wires":[["df8cf0d9b3c78ec7"]]},{"id":"be812d658b23e636","type":"template","z":"65617ffeb779f51c","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"one,two,1.234.567\nthree,four,2.345.678\n","output":"str","x":260,"y":200,"wires":[["004a11f6ac394aef"]]},{"id":"3181904b72341cb3","type":"inject","z":"65617ffeb779f51c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":200,"wires":[["be812d658b23e636"]]}]

```

expression

```auto
$$.payload ~> |$|{"col3": $number( $replace( $.col3,".", "") ) / 100000}|

```

Better still, if you didn't store the number in csv with more than 1 period.

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [8 March 2023 13:09 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/3 "2023-03-08T13:09:41Z")

</div>

Thank you so much E1cid, its works so good!

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [8 March 2023 14:00 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/4 "2023-03-08T14:00:54Z")

</div>

Hi one more time,

Now i find a new problem, the csv that i recive some times the value is 958.245 with only one point and others is 4.248.472 with two points.

When i recive with only one point is read like a number, and with two points like string.

So if i use this code only works when is a string, when is a value because only one point, not works.

Some function to replace both types of data interchangeably?

Thank you in advace.

---

<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:** [8 March 2023 14:12 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/5 "2023-03-08T14:12:25Z")

</div>

Set the csv node to not parse numerical values, then all will be strings.

---

<div class="post-metadata">

**Author:** ![MA.ING](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@MA.ING](https://discourse.nodered.org/u/MA.ING)\
**Post date:** [9 March 2023 11:25 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/6 "2023-03-09T11:25:01Z")

</div>

Thank you, working fine now.

---

<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:** [23 March 2023 11:25 UTC](https://discourse.nodered.org/t/string-with-2-points-from-csv-to-number/76292/7 "2023-03-23T11:25:59Z")

</div>

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