# Select value from CSV file

**URL:** <https://discourse.nodered.org/t/select-value-from-csv-file/45058>\
**Category:** General\
**Created:** [2 May 2021 14:37 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058 "2021-05-02T14:37:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [2 May 2021 14:37 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/1 "2021-05-02T14:37:10Z")

</div>

I made a product selector in node-red dashboard where I can select 3 different products from a csv file.  
The csv file includes a 'takt' value with is corresponding to the product. (column B in csv file)

_ **Product selector:** _

 ![Schermafbeelding 2021-05-02 om 16.26.20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a836d2d272a6a00688299468db11a3e7f91aea38.jpeg)  
 ![Schermafbeelding 2021-05-02 om 16.26.33](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7bfa856f11ebaf41d4cef073fd054371e5fd9a50.png) ![Schermafbeelding 2021-05-02 om 16.29.13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87fe7ebf9bc1afe2388d279bd648a01a9eaada13.png)

I want to use de corresponding 'takt' value from the csv in my flow as well. I searched a lot but I didn't find the right method to do this.

Can anyone help me with the right method?

So I don't need to see the value in my dropdown menu. I only need to use the takt value witch belongs to the selected product.

---

<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:** [2 May 2021 15:25 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/2 "2021-05-02T15:25:08Z")

</div>

Use a change node to move the values from the csv to make an array of product names and value. i.e.

```auto
[{"id":"fde8f8.31889708","type":"inject","z":"9b3f9f31.c45298","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":110,"y":1780,"wires":[["5e502573.725154"]]},{"id":"5e502573.725154","type":"template","z":"9b3f9f31.c45298","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"product,takt\nball,20\ntrain,30\nhat,60","output":"str","x":130,"y":1860,"wires":[["c601359c.1c0a38"]]},{"id":"c601359c.1c0a38","type":"csv","z":"9b3f9f31.c45298","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":250,"y":1900,"wires":[["f6354306.6d98c8"]]},{"id":"f6354306.6d98c8","type":"change","z":"9b3f9f31.c45298","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload.{product: takt}","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":1900,"wires":[["309c8b52.68564c","d86c7482.e5bc68"]]},{"id":"309c8b52.68564c","type":"ui_dropdown","z":"9b3f9f31.c45298","name":"","label":"test","tooltip":"","place":"Select option","group":"8b5cde76.edd58","order":4,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","x":650,"y":1900,"wires":[["d86c7482.e5bc68"]]},{"id":"d86c7482.e5bc68","type":"debug","z":"9b3f9f31.c45298","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"options","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":1800,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

[edit added delete payload and to show options in debug]

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [2 May 2021 15:43 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/3 "2021-05-02T15:43:31Z")

</div>

Yes, but how can I select the corresponding value?

Out of the dropdown node comes the product name. How can I use this to select the corresponding takt value from the csv?

---

<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:** [2 May 2021 15:58 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/4 "2021-05-02T15:58:50Z")

</div>

If you select ball the drop down output will be 20, the value. If this is not what you want you will need to explain more.

[edit if you want the whole product object you could use

```auto
payload.{product: $}

```

which when you select ball will output

```auto
{"product":"ball","takt":20}

```

]

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [2 May 2021 16:22 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/5 "2021-05-02T16:22:03Z")

</div>

If I select product “ball” the only value what comes out of de dropdown node is “ball”.  
The takt value didn’t go true the dropdown node.

I thought I can use value “ball” (what comes out of the dropdown node) in a separate flow to grab the “takt” value out of the csv file. But I don’t know how...

---

<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:** [2 May 2021 16:24 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/6 "2021-05-02T16:24:51Z")

</div>

Here is the screnshot of the output if ball is selected.

 ![Screenshot_20210502-172343](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b653d6251600b99faafaa4862e5bb74be45f683.png)

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [2 May 2021 16:30 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/7 "2021-05-02T16:30:49Z")

</div>

Yes, great!

Can you send me the flow please?  
And do you have a screenshot of the dashboard where you select “ball”?

---

<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:** [2 May 2021 16:31 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/8 "2021-05-02T16:31:50Z")

</div>

it's in post 2.

 ![Screenshot_20210502-173244](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/0/50081faffae7f430d809e76fa308d19939010bf1.png)

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [3 May 2021 15:09 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/9 "2021-05-03T15:09:57Z")

</div>

Thank you @E1cid !!  
That’s what I need. 😀

But I don’t understand how there only a number comes out with the msg.payload. And not the name “ball” ore something. Where is it managed that only the number value is selected?  
Can you explain this to me?

---

<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:** [3 May 2021 15:33 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/10 "2021-05-03T15:33:28Z")

</div>

The option array created in the change node contains the key value objects for each entry. The key is the label and the value is what is returned

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [4 May 2021 19:34 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/12 "2021-05-04T19:34:16Z")

</div>

I think I understand it now. Thank you very much!

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [5 May 2021 13:44 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/13 "2021-05-05T13:44:40Z")

</div>

@E1cid  
Now return the value out of the dropdown node.  
I'm puzzling how to return the label and the value out of the dropdown node... can you help me a little further?

---

<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:** [5 May 2021 14:00 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/14 "2021-05-05T14:00:32Z")

</div>

Post 4 contains the info you require.

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [5 May 2021 16:43 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/15 "2021-05-05T16:43:20Z")

</div>

Actually when I do this the payload is nothing:

 ![Schermafbeelding 2021-05-05 om 18.39.25](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/4/1485aea4bd25d24241e3ebae06c02f89f33b0ece.png)  
 ![Schermafbeelding 2021-05-05 om 18.39.45](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/5/a5e46b3b726a47a920283d0a63c0f5a61ab5b323.png)

---

<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:** [5 May 2021 17:02 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/16 "2021-05-05T17:02:56Z")

</div>

You give no info that can help. Whats the the input to the dropdown  
As it works for me no issues.  
Using exact same flow just the change from takt to $ in the change node.

 ![Screenshot_20210505-180021](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/2269fc5d0ada75994e70e5be9e29424d3076c354.png)

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [5 May 2021 17:09 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/17 "2021-05-05T17:09:11Z")

</div>

Here is my flow:

```auto
[{"id":"97c89a5e.34694","type":"inject","z":"b4370c04.a6c7d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":1520,"wires":[["67700f80.1bdd"]]},{"id":"67700f80.1bdd","type":"template","z":"b4370c04.a6c7d","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"product,takt\nball,20\ntrain,30\nhat,60","output":"str","x":360,"y":1580,"wires":[["c0e5b5dc.9fe7b"]]},{"id":"c0e5b5dc.9fe7b","type":"csv","z":"b4370c04.a6c7d","name":"","sep":",","hdrin":true,"hdrout":"none","multi":"mult","ret":"\\n","temp":"","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":400,"y":1640,"wires":[["63d7a04d.fd528"]]},{"id":"63d7a04d.fd528","type":"change","z":"b4370c04.a6c7d","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"payload.{product: $}","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":1640,"wires":[["b72e9cd3.3baa58","bc09b5df.ea4a5"]]},{"id":"b72e9cd3.3baa58","type":"ui_dropdown","z":"b4370c04.a6c7d","name":"","label":"test","tooltip":"","place":"Select option","group":"a21aeffd.644dc8","order":4,"width":0,"height":0,"passthru":false,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","x":800,"y":1640,"wires":[["bc09b5df.ea4a5"]]},{"id":"bc09b5df.ea4a5","type":"debug","z":"b4370c04.a6c7d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":1560,"wires":[]},{"id":"a21aeffd.644dc8","type":"ui_group","name":"Group 2","tab":"80b00f09.0a7c7","order":2,"disp":true,"width":6},{"id":"80b00f09.0a7c7","type":"ui_tab","z":"","name":"Products","icon":"dashboard","order":4,"disabled":false,"hidden":false}]

```

When I select "ball" in the dashboard. Nothing comes out. 🤔

Edit: This is the original flow I got from you, the only thing I changed is: payload.{product: $}  
As you described in post 4

---

<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:** [5 May 2021 17:17 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/18 "2021-05-05T17:17:29Z")

</div>

Did you go to the dashboard product tab and select a item from the dropdown?

The first payload in empty as it is deleted and it is the debug after the change node. The second debug is after ball is selected from the dropdown.

 ![Screenshot_20210505-181600](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/c/9ce0e8791dde82f501e25535243b2be5bf03154b.png)

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [5 May 2021 17:21 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/19 "2021-05-05T17:21:42Z")

</div>

Yes, but I get different result than you have:  
The first payload is undefined. (result the same as you have)  
The second payload is "" (different result)

 ![Schermafbeelding 2021-05-05 om 19.22.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/be5605de782f0ea68f55bf8910414dd95d1db909.jpeg)

Update: I selected the item "ball" (and the result is "")

 ![Schermafbeelding 2021-05-05 om 19.25.17](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a06065b18c4a6ff4afb6c25409e3ef66ea7e036c.png)

---

<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:** [5 May 2021 17:27 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/20 "2021-05-05T17:27:46Z")

</div>

Strange, Do you have another drop down from another test, are you selecting the correct dropdown?

If you put a debug after csv node what do you get?

if you remove the delete payload from the change node, and sset the debug to show complete message, what do you get?

[edit]  
Thats the home group, the flow you sent me is products

 ![Screenshot_20210505-182904](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/2803e0acb2a8a24bd572c100837cb4fcc89a1cdb.png)

---

<div class="post-metadata">

**Author:** ![MrWolff](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrwolff/32/30557_2.png) [@MrWolff](https://discourse.nodered.org/u/MrWolff)\
**Post date:** [5 May 2021 17:32 UTC](https://discourse.nodered.org/t/select-value-from-csv-file/45058/21 "2021-05-05T17:32:38Z")

</div>

I deleted the first flow, this was in products tab of the dashboard.  
The second flow is in the Home tab.  
I only use the home tab now.

This is what I get when I don't delete the msg.payload.  
The first message is when I hit the inject node.  
The second message is when I select "ball" in the Home tab.

 ![Schermafbeelding 2021-05-05 om 19.29.50](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/c/4c073c1b31464c456bdec05aa6ca522ef630a7b2.jpeg)

[Next page](https://discourse.nodered.org/t/select-value-from-csv-file/45058.md?page=2)
