Please tell me how to add as many rows as meet the conditions

image

I want to read each row of a csv file and if the value of end date - start date is 4 then I want to append 4 corresponding same rows. I’m not sure how to approach this.

@Benimaru,

You can achieve this using the Read CSV activity to read the CSV file row by row, and then use a combination of activities to calculate the difference between the end date and start date, and to append rows accordingly. Here’s a step-by-step guide:

  1. Read CSV File: Use the Read CSV activity to read the CSV file and store the data in a DataTable variable.

  2. Loop Through DataTable: Use a For Each Row activity to loop through each row in the DataTable.

  3. Calculate Date Difference: Inside the loop, use Assign activity to calculate the difference between the end date and start date. Assuming your start date and end date columns are named “Start Date” and “End Date” respectively:

row("Date Difference") = CInt(row("End Date")) - CInt(row("Start Date"))

  1. Check Date Difference: Use an If activity to check if the date difference is 4.

  2. Append Rows: Inside the If activity, use a For Each activity to loop 4 times and add the current row to a new DataTable or a list variable.

  3. Write Output: Finally, use the Write CSV activity to write the appended rows to a new CSV file.

Thanks,
Ashok :slightly_smiling_face: