Importing CSV into dropdown

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 (1.9 KB)

debug

what does your CSV look like?

its just all those names in one column
image

Try replacing your change node with this function node

[{"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:

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

[{"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}]

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

Thanks for the reply,
image
this msg pops up when i run it with a csv node

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

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