Hi there, result wise your approach will work as you are expecting. But as per standards and process improvisation, below are some of the points that I would like to highlight. Please consider these points and you can modify your workflow:
-
Multiple loops - You have declared two for loops. One for data table (Loop1) and other for list collection (Loop2). You are instantiating the list every time you fall into the Loop1 and adding the column value into the collection. This means, for every row there will be only one item in each of the list collections. Hence Loop2 is not required here. Even you are looping through Loop2 but not utilizing the loop value. i.e., item. Instead directly accessing loop for the 0th item.
-
List collections - You are instantiating list collections for every row item which comes with the cost of memory and space. Additionally, the you are assigning values from row to list collection but some of these collections are not used anywhere in your workflow. The one list collection you are using is to check the value, which can be achieved by directly checking the column value in the row as well. This will reduce lines of code as well as processing time.
-
Accessing Columns - You have used column indexes to access the columns. But in real scenarios sometime the columns might not be in the same order that you are expecting. Hence its preferred to refer column names instead of column indexes.
Hope this will help you!