Create table from document and return value if found

datatable
activities

#1

Hello,

I need to screenscrape a document and then get numbers connected to a given name. I have crated tha document into a table and try to get it by using a If activity.

Robot 1

I can’t get the value, it returns empty. The value looks like this: VALUE 1234567


#2

Hi There,

I’m not sure exactly, but I noticed you used a Wildcard *
You can’t use Wildcards in conditions like that. You can, however, use .Contains or .StartWith or Regex, or many other methods.

I would recommend something like this in the condition field:
rowItem.ToUpper.Contains(“VALUE”)
or
rowItem.ToUpper.StartsWith(“VALUE”)

If it’s more dynamic you might need Regex but your condition seems simple enough.

Hope that helps.

Regards.


#3

Hello,

I tried using the recommended one with rowItem.ToUpper.StartsWith(“VALUE”)

This did not work. See attached picture.


#4

I did wrote rowItem.ToString.StartWith(“VALUE”), that did work.


#5

Sorry about that. Yeah .StartWith
When you type the period (.) it should list all the functions that you can use with your string. Hope that helps further. :wink:


#6

No worries!

rowItem will now came out as “VALUE 12345”. How could a then remove "VALUE ", and just assign the numbers to a new variable?


#7

Sure, there are various ways to do that.

Assuming this is consistent you can simply just .Split the string and pull the 2nd element or remove the string “VALUE"
rowItem.ToString.Split(” “c)(1)
or
rowItem.ToString.Split({” “},System.StringSplitOptions.RemoveEmptyEntries)(1)
or
rowItem.ToString.Replace(“VALUE”,”").Trim

You can also use a Regex Pattern
System.Text.RegularExpressions.Regex.Replace(rowItem.ToString,"[a-zA-Z]","").Trim
or
System.Text.RegularExpressions.Regex.Match(rowItem.ToString,"[0-9]{1,10}").Value

I typically use the .Split() most of the time


#8

Thanks! Will this be done in “Assign” activity?


#9

Hello,

How could i select which column to look for the value in?

???.StartWith(“4”)


#10

2 Ways.

For each row In dt1
    row.Item("columnname").ToString.StartsWith("4")
    or row.Item(columnIndex).ToString.StartsWith("4")

or

dt1.Rows(rowIndex).Item("columnname").ToString.StartsWith("4")
or dt1.Rows(rowIndex).Item(columnIndex).ToString.StartsWith("4")

Regards.


#11

Hi @andnesper,

You can use below code to get only column value start with 4.
Dt=Dt.Select("ColumnName like '4℅'"). CopyToDataTable()

If you want to count of the column name start with 4 then use below code.
IntCount=Dt.Select("ColumnName like '4℅'").length

Regards,
Arivu :slight_smile:


Filter column on 'value starts with ...'