How to add empty row in a data table in this scenario?

Hello everyone !
I have two data table “dt_1” and “dt_2”, they both are sorted in required manners , i want to check each row from both data table using column “TrackIDNumber”, if “dt_1” row is not matched with “dt_2” then i want to add empty row in “dt_2”.

I am doing this so that at later on i can join two table in excel and show to client as per their req.

hi,
this should work

IF(CurrentRow(“TrackIDNumber”).ToString.CompareTo(CurrentRow2(“TrackIDNumber”).ToString) =0)

@prabin_chand1

A question here…so you want to compre first row of first dt with first row of second dt and so on?

If yes…then say first rows are not matching and we inserted a row in dt2…now the same first row is second in dt2…so now you want to compre second of dt1 with the ideal first which is second now because of empty row in dt2?

Cheers

yes you are right,
How can i do that ?

@Anil_G
@Catfish1115

At last i will join these table so that it will look like this,

@prabin_chand1

Then follow the steps

  1. Use a for each row in datatable on dt1 (where you dont insert any rows) and assign a variable to the index property of the for loop
  2. Then use if condition with currentrow for dt1 and dt2.Rows(index) to get the same row from dt2 and compare on the columns needed
  3. If not matching then use insertat method using a invoke method activity and insert a blank row using the same index value from for loop

Cheers

is this ?

@prabin_chand1

Almost…but indexsrow should eb assigned to index in the for loop properties so that it auto increments

Methodname to be InsertAt

And in arguments need to pass the index and row as parameters

Cheers


@prabin_chand1

InsertAt should be the name please remove brackets and loop index

And in arguments provide the index as int32 and then datarow as second argument

Cheers

@prabin_chand1

As you need emoty row you can just provide {}

Cheers


@prabin_chand1

My bad …it should be dt_two.NewRow()

Cheers

Same Error !

image
Try this will add one raw to a data table with three columns

@prabin_chand1

Sorry for the delay and wrong response. please check this

implementation should be on dt.Rows and datarow as first parameter and index as second

cheers