Error message get row item

Hi Guys,

i Keep getting an error message which is driving me crazy. Please find attached the screenshot of my workflow. I would like to extrat certain data from an excel file via the get row item. I am using the get row item because i need to get information from the 6th collum. Everything seems to be working fine. However, when i run the process i get the following error. It does however work correctly when i try using a message box i get the correct value shown to me. Can someone pls assisst?prtscreen%202

Can you attach workflow? Have you passed column index or name

Main.xaml (31.4 KB)

Hi Prankurjoshi.

Please see attached.

Thanks for the help.

Hi,

I found the error (some values in the excel file have less digits than others. Do you have any idea how i fix this with an IF function (some contain 12 digits and other 14)?

Hi @Matthewvz

Seems like you could use some regex to solve the issue.
Could you give a sample mockup of your string from the aanslagnummer variable?

In case it is followed by a space, you could assign BSN this value:
System.Text.RegularExpressions.Regex.Match(aanslagnummer,"\d{12,14}").ToString

Here is how it works: https://regex101.com/r/QiD9O9/1/
image

Hi Thank you for your reply,

I have an additional question. When i try to use the get row item and the assign function i get the error when the information in the table in excel stops (most likely because is selected the 6th collum index and it trys to assign something to a a cell with no value. How do i fix this?

Your Assign activity is throwing an error: Index was out of range. If you see here, you will find out that it is the issue with the .SubString method:
image

The regex solution will work better, because it will simply find your value or return empty string (without an error).

The Get Row activity is working as it should - it returns your value from 6th column of the table (and can return an empty string if there is no value in that row).

Thank you for your reply!!

Could you please provide me with a sample of the regex (as i am new to UIPATH). the total aanslagnummer looks something like this 215370261H3601. With the BSN i just want to extract the first 9 digits. How do i do this with regex?

Try this in an Assign activity:
BSN = System.Text.RegularExpressions.Regex.Match(aanslagnummer,"^\d{9}").ToString
and see how the expression works here: https://regex101.com/r/QiD9O9/2

It will extract 9 digits starting at the beginning of your string

Thank you so much ! the bsn is working now. Just for my understanding, how would the code look if i wanted the last 4 digits? (digits 10 till 14)?

This should cover it:
\w{5}$

System.Text.RegularExpressions.Regex.Match(aanslagnummer,"^\w(5)$").ToString

So like this? because it isnt working

No no, without ^ at the beginning
^ means start of line
$ means end of line

^\d+ matches digits from the beginning
\w+$ matches word characters from the end

1 Like

@loginerror Hi, I am trying to do something similar with regex however its not working

My code is this
System.Text.RegularExpressions.Regex.Match(row, “(?<=S—CLOAD NO)\w+”).ToString

This is a small extract of my text
S—CLOAD NO A12345-AAB ARGRG
S—CLOAD NO A127921-SM001 RWGRW
S—CLOAD NO A133—AAB NOFAFNER

I need to extract the 'a12345" part from the strings.
But my code isn’t working. Any idea why?

@sangasangasanga

You got it right but are missing a space after “NO”.
Your regex:
(?<=S—CLOAD NO)\w+
Corrected:
(?<=S—CLOAD NO )\w+

This should catch what you need. See here for reference :slight_smile:

1 Like