Reformatting text in Data Table

excel

#1

Hi Guys,

I’m looking for a way to reformat 2 columns in my data table. One is province, the other is country. My logic so far is a for each row activity with an if statement that will iterate through the specific columns to check for the format rule.

the rule I’m trying to create is,
IF Country = “Canada” then write CAN
IF Province = “Manitoba” then write MB
IF Province = “Quebec” or QC then write PQ
IF Province = “Newfoundland” or NF then write NL

beginning: for each activity of the data table
image

example: decision tree iteration for country
image

sorry for the pseudo code, my syntax for uipath isn’t the best.

Thanks,


#2

Hi,

You can utilize switch activity. Please refer the below example.

Expression: strArray.FirstOrDefault(Function(s) url.Contains(s))
StrArray: Patterns to be found are given in the string array.
Cases: For each pattern, necessary activities need to be given
Switch Case type must be string.(found in the properties pane)

image

Hope it will be useful for you.

Regards,
Saranya K R


#3

do you mind clarifying the logic as to why i would use this function?


#4

here is my logic so far for country

for each iterates through the datatable
image

not sure about the syntax here


i get this error here

write over cell with Canada with CAN
image


#5

Hi,

First all the values need to be stored in a string array of province values. e.g “manitoba”, “quebec”.
Take a switch activity and give the expression as
strArray.FirstorDefault(Function(s) province.contains(s))
Then write the cases,
manitoba
Write Line - MB
quebec etc
Write Line - PQ

Hope it helps to understand better.