# Importing CSV into dropdown

**URL:** https://discourse.nodered.org/t/importing-csv-into-dropdown/33025
**Category:** Dashboard
**Created:** [18 September 2020 08:48 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025 "2020-09-18T08:48:44Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Gromilicious](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@Gromilicious](https://discourse.nodered.org/u/Gromilicious)
#### Post date: [18 September 2020 08:48 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/1 "2020-09-18T08:48:44Z")

</div>

Hi all,

I am able to extract data from a csv however when i dry and display all the names in a drop down all that is displayed are the column name (col1) i have been stuck on this for a while now and haven't been able to find other forums to help  
ty in advance  
regards gurpreet  
[flows (2).json](https://discourse.nodered.org/uploads/short-url/gQ09InSk8KJT8jqmciMRFs8HYJz.json) (1.9 KB)

 ![dashboard error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/c/dcaf3076443bbd82ccef1949ea82d8487f7745fb.png) ![debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/ab384af9dc60c6a7cd6c0272d643ea08fc08c9c8.png) ![drop down file](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0fe23f649354c41af27c15f83c3ae4f02e1ff2e9.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: [20 September 2020 16:16 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/2 "2020-09-20T16:16:27Z")

</div>

what does your CSV look like?

---

<div class="post-metadata">

### Author: ![Gromilicious](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@Gromilicious](https://discourse.nodered.org/u/Gromilicious)
#### Post date: [21 September 2020 02:08 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/3 "2020-09-21T02:08:56Z")

</div>

its just all those names in one column  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/0/702685d65597d22c00788e88f00f68961ac2925f.png)

---

<div class="post-metadata">

### Author: ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)
#### Post date: [21 September 2020 10:33 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/4 "2020-09-21T10:33:05Z")

</div>

Try replacing your `change` node with this `function` node

```auto
[{"id":"93cf18f7.648228","type":"function","z":"b908a1ba.400e38","name":"","func":"var arr_in = msg.payload\nvar arr_out = [];\nvar i = 0\n\nvar l = arr_in.length\n\nfor (i=0; i<l; i++) {\n node.warn(arr_in[i])\n arr_out.push(arr_in[i].col1)\n}\n\nmsg.options = arr_out\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":260,"y":280,"wires":[["8d620f60.e8e408","170dd955.f867bf"]]}]

```

the result will look like this in the dropdown:

 ![Screen Shot 2020-09-21 at 6.32.29 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a9c8bb83af8d468de65412c7c3577074f42e3b02.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: [21 September 2020 14:07 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/5 "2020-09-21T14:07:40Z")

</div>

As there are no commas in the list try spliting with function

```auto
[{"id":"409f31d6.314f2","type":"inject","z":"b8ba3471.55b8a8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":690,"y":480,"wires":[["4996a9f9.9080a"]]},{"id":"4996a9f9.9080a","type":"file in","z":"b8ba3471.55b8a8","name":"","filename":"/storage/emulated/0/Download/test.csv","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":930,"y":540,"wires":[["1fbcd608.5850a2"]]},{"id":"1fbcd608.5850a2","type":"function","z":"b8ba3471.55b8a8","name":"","func":"msg.options = msg.payload.split(\"\\n\");\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":400,"wires":[["1c757f68.76aa89","ae1eb4bd.a6f8e8"]]},{"id":"ae1eb4bd.a6f8e8","type":"ui_dropdown","z":"b8ba3471.55b8a8","name":"","label":"","tooltip":"","place":"Select option","group":"ac0f8480.463678","order":5,"width":0,"height":0,"passthru":true,"multiple":false,"options":[],"payload":"","topic":"","x":1300,"y":480,"wires":[[]]},{"id":"ac0f8480.463678","type":"ui_group","z":"","name":"Customers","tab":"1a45c0bd.8b5877","order":2,"disp":true,"width":"14","collapse":false},{"id":"1a45c0bd.8b5877","type":"ui_tab","z":"","name":"Positive Test","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Gromilicious](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@Gromilicious](https://discourse.nodered.org/u/Gromilicious)
#### Post date: [22 September 2020 01:19 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/6 "2020-09-22T01:19:42Z")

</div>

ty i i figured out i had to put it into another array just couldn't figure out the function guess i gotta freshen up my basic coding skills again Thanks alot

---

<div class="post-metadata">

### Author: ![Gromilicious](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@Gromilicious](https://discourse.nodered.org/u/Gromilicious)
#### Post date: [22 September 2020 01:20 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/7 "2020-09-22T01:20:57Z")

</div>

Thanks for the reply,  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/33b72d287dedb69e55b47a901b78f77ba0105716.png)  
this msg pops up when i run it with a csv node

---

<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: [22 September 2020 06:04 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/8 "2020-09-22T06:04:21Z")

</div>

Stramge, what is the value of msg.payload, have you removed th csv node as it is not required, the function goes after the file in node

---

<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: [6 October 2020 06:04 UTC](https://discourse.nodered.org/t/importing-csv-into-dropdown/33025/9 "2020-10-06T06:04:23Z")

</div>

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