This works great when you need to add validation or extra logic later. You can easily throw in a check to make sure both arrays match in length before processing. Performance is basically the same for normal Zapier workflows, but this structure makes debugging way easier when stuff breaks.
This splits both input strings by commas, then pairs each product ID with its matching category ID using the same index position. The trim() removes any extra spaces around values. Finally, it joins everything with newlines to create your CSV format. Just make sure your Zapier input field names match what you’re referencing in the code.