FOR EACH LOOP does not allow Remove Datarow Activity during it’s iterations. You can use datatable.select to filter if you want but if you want a simpler but extremely powerful method use this. The reason this is powerful is that you can put as many conditions on as many columns as you want. It’s powerful because of simplicity but performance wise it is not the best with Uipath.
- The source of datatable may be an excel or may be a CSV
- Test the Algorithm for performance if your input file is more than 0.5 GB.
*Test and Use at your own Risk. If you find a bug please share with us.
- Set Total_in_records as an integer dtb_in.rows.count() before the while loop . We will use this as EOF(end of File) to end the while iteration.
2) Intialize Ctr_loop = 0 . This is our index
3) Use the DO while loop as below.
In my case I am removing the column “comp” =“0” you can change it to nulls or blanks by comparing with ="" ( two double quotes) .
If you remove rows the EOF reduces by 1. so total_in_record is reduced by 1 with each remove.You also do not have to ctr_loop++ because the current record is removed and the positions of the subsequent rows have changed by -1 .** Basically your datatable is shrinking shorter so your counters have to adjust themselves
4) I have read the dataable with headers and I can use as many conditions on as many columns as I want.