Best answer

Filter CSV rows out depending on the value of a field

  • 9 March 2020
  • 2 replies
  • 428 views

Userlevel 1

I have a Zap where I import a CSV and then later down the line I want to filter out some rows depending on the values within that row.


Example CSV:

id,name,color

1,john,red

2,mary,blue

3,sam,red


In this CSV, I only want to proceed with people who are tagged as red. I tried to accomplish this using the "Run JavaScript" app, but even though I return an array of data, it seems to only return 1 row. Does anyone know how to do this? Thanks.


icon

Best answer by druppe 9 March 2020, 18:25

When a Code step returns an array of data, it's interpreted as multiple instances of single rows of data -- your subsequent steps in the Zap will trigger on each row individually, and in the preview, you're only seeing the first row. It can be very useful, but probably not what you want in this case.

You should be able to have your code step return a single object containing an array, like

return {data: your_filtered_csv_data};


View original

This topic has been closed for comments

2 replies

Userlevel 1

When a Code step returns an array of data, it's interpreted as multiple instances of single rows of data -- your subsequent steps in the Zap will trigger on each row individually, and in the preview, you're only seeing the first row. It can be very useful, but probably not what you want in this case.

You should be able to have your code step return a single object containing an array, like

return {data: your_filtered_csv_data};


Userlevel 1

I think this did the trick! I am working on some other issues with my Zap, but this part seems to be fixed! Thanks!