Need some clarification of error handling from excel column Values

My use case is Excel have 3 columns …these three columns
1st column is First Name
2nd column is Last Name
3rd column is City,State,Zipcode.
in these 3rd column value need to Split by (,)Commas,But these columns one row does not have Zip Code…Split up the Values and using add Datarow to Add the values to New Excel Sheet…
In this scenario…Zipcode splitup which row is not available in Zipcode Exception Occured…how handle this condition…


Try to make a condition check if string.isnullorempty(columnname) then made a custom exception in throw activity else : split up and add the values using datarow activity

when only ZIPCode is optional, maybe the following can help (Filling up)

Assign Activity
miniItemArray =

 strTest1.Split({","}, StringSplitOptions.RemoveEmptyEntries).Select(Function (x) x.Trim).Append(nothing).Take(3).Cast(of Object).toArray

Feel free to shorten the longer oneliner by breaking it into subtasks


3rd column need to split up then only i can get zip, how can i give a condition in column name ,it throwing error in spliting value variable…

Hi @nirmalad123

Do you mean the 3rd column has values separated by comma and when ZIP CODE value is not present split index changes?

a,b,c,zip code value, e index 3-> zip code
a,b,c,e index 3 → e

If so and you only need to get ZIP code from your 3rd column is better check and extract ZIP CODE using regex instead split method


some rows Zip code is not available in that input excel sheet … In that Row only showing index out of boundary exception…when i used split up function it is fine which row is available zip code…

This is my input file

This is my Output File format …
here Zip is not available in 3rd row …Throwing index out of boundry Error.which one is using spilit functions

Thank for the clarification @nirmalad123

You can check if index exists before use it in a if activity


ElementAtOrDefault = Returns the element at a specified index in a collection or a default value if the index is out of range (null value)

But I suggest use regex instead if this text format can be change in future (more commas and values, for example)

we gave you an option and also showcased on how to handle above:

And also going further within the prototyping with a minified test set:

Resulting to

dtResult =

(From d In dtData.AsEnumerable
Let fln = String.Format("{0} {1}", d("First Name").toString.Trim, d("Last Name").toString.Trim)
Let arrSplit = d(3).toString.Trim.Split({","}, StringSplitOptions.RemoveEmptyEntries)
Let ra1 = arrSplit.Select(Function (x) x.Trim).Append(Nothing).Take(3)
Let ra = ra1.Prepend(fln).Cast(Of Object).toArray
Select r = dtResult.Rows.Add(ra)).CopyToDataTable

We can also adapt and as more, we can rely on Patterns (e.g. States always with (XX) ) we can enhance by more detailed parsing City,State,Zip

1 Like


Thanks for your Answer.i got expected output… can you explain this query…

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.