Skip Empty rows & Match the rows with a string

Hello Guyz
Hope you all are doing great…
Im begginer in uipath & Im stuck in this scenario

So my case is…

lets say theres a array of Languages i.e "english,Hindi,Spanish,…etc)
so a for each loop will iterate through & will pick a language
Then refer to this Excel file

here the language & its transalation is present & my agenda is
Within the 1st for each loop…another for each row will be used then…based on the language (from the array)
it will match the language from the excel & then will write its transaltion

but as you can see there are some white spaces(within the rows)

So my 1st question what is the exppression to skip the white spaces of(empty rows) & read the valid row column from the excel

Then
2nd question is=
what is the expression which can match the language value with the row value of the langauage(from the excel)

Please help me out

Thanks a million

1 Like

Hey @Jiban_Stars

Below may help you…

dt.AsEnumerable.SkipWhile(Function(row) String.isNullOrEmpty(Convert.ToString(row("Language"))) AndAlso String.isNullOrEmpty(Convert.ToString(row("Translation")))).CopyToDataTable

Use the above statement in the for-each row source.

I’m assuming you are using item in the for-each and currentRow in the for-each row as iteration object.

CurrentRow("Language").ToString.ToLower.Trim.Equals(item.Trim.ToLower)

Thanks
#nK

Thank you so much
your nd solutio is working fine

But for the 1st solution, can you please provide me any simple alternative…(No usage of LinQ)
a simple .net expression to skip the blank rows ?

Thanks

1 Like

for training purpose we can recommend to do the first implementation steps and exploring

  • for each row, filter datatable …

Going ahead with the learning you can explore dictionairies and LINQ

Excelscope & read range - dtData

Assign Activity
LHS: dictTranslations | Dictionary (Of String, String)
RHS:

(From d in dtData.AsEnumerable
Where Not (isNothing(d(0)) OrElse String.IsNullOrEmpty(d(0).toString.Trim))
Select r=d).ToDictionary(Function (x) x(0).toString.Trim.ToUpper, Function (x) x(1).toString.Trim

Afterwards you can Access the translation with the Language as Key
dictTranslations(“ENGLISH”) will return Hey, how are you?

With a change to the Country Codes like EN, IT, ES … the key can be oragnized more short and clear

No LINQ approach can be started with Filter DataTAble activity

Hey @Jiban_Stars

Just use a IF loop inside For-each row

Condition

String.isNullOrEmpty(Convert.ToString(row("Language"))) AndAlso String.isNullOrEmpty(Convert.ToString(row("Translation")))

Then Sequence Block

Do Nothing, Just use Continue activity of required

Else Sequence Block

The row comparison which was already mentioned above

Hope this helps

Thanks
#nK

Filter data table is best solution