Use data from 2 arrays

Hi,

I am building a flow to extract dates for emptying garbage bins in our street from a website.
The type of garbage and the date are entered in two separate arrays.

How can I combine those two and read the right date for the type of garbage from the array?

Current flow:

[{"id":"eb8f35dd.1ccf98","type":"tab","label":"Afval kalender","disabled":false,"info":""},{"id":"f925e67a.9d9528","type":"inject","z":"eb8f35dd.1ccf98","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":140,"wires":[["a5a21a6e.18b198"]]},{"id":"a5a21a6e.18b198","type":"http request","z":"eb8f35dd.1ccf98","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://www.radhw.nl/inwoners/ophaalschema?p=3261+PH&h=1","tls":"","persist":false,"proxy":"","authType":"","x":290,"y":140,"wires":[["214bae89.ea7942","c2217819.1b9898"]]},{"id":"214bae89.ea7942","type":"html","z":"eb8f35dd.1ccf98","name":"","property":"payload","outproperty":"payload","tag":".datum","ret":"html","as":"single","x":450,"y":140,"wires":[["50c48c70.76cf24"]]},{"id":"c2217819.1b9898","type":"html","z":"eb8f35dd.1ccf98","name":"soort","property":"payload","outproperty":"payload","tag":".soortafval*","ret":"text","as":"single","x":450,"y":240,"wires":[["b535724d.5ac1e"]]},{"id":"f43f7092.7f421","type":"join","z":"eb8f35dd.1ccf98","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"soort","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":710,"y":180,"wires":[["d4f48ef2.33287"]]},{"id":"d4f48ef2.33287","type":"debug","z":"eb8f35dd.1ccf98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":850,"y":80,"wires":[]},{"id":"b535724d.5ac1e","type":"function","z":"eb8f35dd.1ccf98","name":"part 1","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 0;\nmsg.parts.count = 2;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":240,"wires":[["f43f7092.7f421"]]},{"id":"50c48c70.76cf24","type":"function","z":"eb8f35dd.1ccf98","name":"part 2","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 1;\nmsg.parts.count = 2;\nreturn msg;","outputs":1,"noerr":0,"x":590,"y":140,"wires":[["f43f7092.7f421"]]}]

Output:
Knipsel2

Hi & welcome to the forum.

In order to make code more readable and importable it is important to post it between two sets of three backticks - ``` - see this post for more details - How to share code or flow json

Please go back and edit your post.

It would be good if you could also post a screen shot for those of us on a mobile (or for those who have zero interest in loading up your flow but might be happy to reply with a solution)

Hi Steve,

Thanks for the tip.

Much better :slight_smile:

here are a couple of ways (I'm certain there are better ways)

[{"id":"4bf509d4.404e08","type":"inject","z":"284fa9c6.f473c6","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":140,"wires":[["4d6bc65e.554338"]]},{"id":"4d6bc65e.554338","type":"http request","z":"284fa9c6.f473c6","name":"","method":"GET","ret":"txt","paytoqs":false,"url":"https://www.radhw.nl/inwoners/ophaalschema?p=3261+PH&h=1","tls":"","persist":false,"proxy":"","authType":"","x":270,"y":140,"wires":[["4ceef695.938588","982c0533.ba3e48"]]},{"id":"4ceef695.938588","type":"html","z":"284fa9c6.f473c6","name":"","property":"payload","outproperty":"payload","tag":".datum","ret":"html","as":"single","x":430,"y":140,"wires":[["9d93f167.6386c"]]},{"id":"982c0533.ba3e48","type":"html","z":"284fa9c6.f473c6","name":"soort","property":"payload","outproperty":"payload","tag":".soortafval*","ret":"text","as":"single","x":430,"y":240,"wires":[["2d257e4.03a6a82"]]},{"id":"df902e16.c5dfb","type":"join","z":"284fa9c6.f473c6","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"soort","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":690,"y":180,"wires":[["7317470f.fc3eb8","82f9eded.60ce2"]]},{"id":"2d257e4.03a6a82","type":"function","z":"284fa9c6.f473c6","name":"part 1","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 0;\nmsg.parts.count = 2;\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":240,"wires":[["df902e16.c5dfb"]]},{"id":"9d93f167.6386c","type":"function","z":"284fa9c6.f473c6","name":"part 2","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 1;\nmsg.parts.count = 2;\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":140,"wires":[["df902e16.c5dfb"]]},{"id":"7317470f.fc3eb8","type":"function","z":"284fa9c6.f473c6","name":"combine as key/val","func":"var names = msg.payload[0];\nvar dates = msg.payload[1];\nvar combined = {};\n\nfor (let i = 0; i < dates.length; i++) {\n    combined[dates[i]] = names[i];\n}\n\nmsg.payload = combined\nreturn msg;","outputs":1,"noerr":0,"x":890,"y":120,"wires":[["7d2644d4.85519c"]]},{"id":"82f9eded.60ce2","type":"function","z":"284fa9c6.f473c6","name":"combine as array of objects","func":"var items = msg.payload[1];\nvar dates = msg.payload[0];\nvar combined = [];\n\nfor (let i = 0; i < items.length; i++) {\n    let newObj = {\n        item: items[i],\n        value: dates[i]\n    }\n    combined.push(newObj)\n}\n\nmsg.payload = combined\nreturn msg;","outputs":1,"noerr":0,"x":900,"y":240,"wires":[["d8f49f2d.655"]]},{"id":"7d2644d4.85519c","type":"debug","z":"284fa9c6.f473c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1110,"y":120,"wires":[]},{"id":"d8f49f2d.655","type":"debug","z":"284fa9c6.f473c6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1110,"y":240,"wires":[]}]

EDIT...

as for accessing the path to these items, use the "copy path" button that appears when you hover over a debug value

Hi Steve,

That helped me a lot.
Thank you for your help.

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