Checking next row with (counter+1) but when table have no Row It gives Error

Back to my old script…

I start with assign (intRowCounter = 0)
IdOnCurrentRowIsEmpty = dt1.Rows(intRowCounter)(“Id”).ToString = “”

Then I created this to find if my next row has a ID or not…
IdOnNextRowIsEmpty = dt1.Rows(intRowCounter+1)(“Id”).ToString = “”

and then at the end Im doing
intRowCounter = intRowCounter+1

image

it works as long my table has next row…
When im at Id (140 or 150) its works but it gives Error when I reach to current row id (160) it gives error on Assign - ‘IdOnNextRowIsEmpty’: There is no row at position 5.

I want to register that Id 160 also in system and get a sysid from system to that sysid colum… which I can not do right now as its giving error on assign.
how to solv this … can someone help…

Hi.
Can you please explain why you are trying to check if the next row city name is empty or not?

sorry it was ID not city

Okay. If the next row ID is empty, what is the next step that you are supposed to do ?

make it easy for you…
can you tell how can i still register the last row into system…

Act this problem occure when i have an excel file which have no row which has empty ID. like this

image

My solution is working perfect and I can register the row id 160 into system… until i have this yellow row in the file which im getting from system…

That is the reason why I’m doing ekstra step by checking next row = IdOnNextRowIsEmpty.

But when i have not that yellow line on Excel file…
image
Then I can not register the id 160 into system due to my activity (IdOnNextRowIsEmpty) gives error…

Instead of checking if the next row is empty, can we check if contains the word “Total” in it ? This way that particular error won’t come.
Please refer the attached screenshot also.

I have to check on ID as it is uniqe
I can not check the total as what if in one file there is no total word exist.

@ppr @Palaniyappan @balupad14 @Pradeep_Shiv

can someone help me on that…

@Latif Why are you checking dt1.Rows(intRowCounter+1)(“Id”).ToString = “”, most probably this is the Expression throwing you the error.

When you try to use an Index value that is greater than the total number of values present, you will get the error.

Also, I guess you are using While Loop to iterate through the rows, can you not use For Each Row ?

Can you show the Workflow Screenshots that you have implemented, maybe we can understand and analyse better.

Im using a for each row and its true that this code (dt1.Rows(intRowCounter+1)(“Id”).ToString = “” ) is giving me an error.
ExcelFile_1.xlsx (9.0 KB) ExcelFile_2.xlsx (10.1 KB) NextRowValue.xaml (27.9 KB)

Here is the flow and files…
the reason I want to check the nextrowvalue is … sometime i have same use exist 2 time with different price in file… and i do not want to register 2 cases on same user så to avoid that i need to get nextrow data at the same time when i know my next row is same…
and its working…
but problem is due to the difference data of files when my file have Not a row with empty ID number in last its giving error. but the file which have an empty row it working perfect.

Can you help @supermanPunch or anyone else?

@Latif

Check as below for your reference
https://forum.uipath.com/t/rpa-datatable-get-previous-row-column-value-set-to-current-row-column-value/256199/2

Hope this helps you

Thanks

I think this will solve your problem, put it in a if action. It checks if the Colum in the row the loop is currently in is empty.

String.IsNullOrEmpty(dt1.Rows(Rowindex or Rowname)(Columindex or Columname).ToString) = False/True… then/else

But obviously you would use in your case a variable Rowindex not the name.

if you want to check for if all colums in the specific row are empty then simply add more like:
String.IsNullOrEmpty(dt1.Rows(Rowindex or Rowname)(Columindex or Columname).ToString + (dt1.Rows(Rowindex or Rowname)(Columindex or Columname).ToString +(dt1.Rows(Rowindex or Rowname)(Columindex or Columname).ToString + …) =…

let me know if this helped you