Splitting an item in for each activity

Hello!

I have a question about splitting items in a for each. For the process I’m developing, I am taking a column from a spreadsheet using a read column activity. I am then using a for each activity for the data taken from the spreadsheet. I am attempting to split the item at a special key (~), so I have two substrings I can set as separate variables. For example,

example_jobName~daily

I tried to use .Split but this has a validation error. Screenshot below.

image

Does anyone have any solutions or ideas?

Thanks in advance!

2 Likes

Hi @william.coulson

What is the data type argument of your foreach ?

cheers :smiley:

Happy learning :smiley:

4 Likes

Hey @pattyricarte,

Should’ve specified that! The SearchData variable for the For Each is IEnumerable(Object), the brackets are <>

1 Like

yes because you are using the split method .Can you try to get the value of item?

cheers :smiley:

Happy learning :smiley:

3 Likes

Hi @william.coulson,

itemSplit(dataType should be array of string) = split(“~”, item.tostring.trim)

Try this.

Thanks!

2 Likes

Hi @kadiravan_kalidoss,

I tried what you’ve suggested, it is still showing the same validation error as above

2 Likes

Hello,

check foreach Type argument property, if its Object or other than change to string.

Thank,
Sunil Patel.

2 Likes

Hi @william.coulson

use this in the Assign Box
ItemSplit = item.Split(“~”.ToCharArray)(0)

This is for getting jobName, If you wanto to take the latter then instead of index 0 put as 1

5 Likes

Hello,

try with this syntax convert.tostring(item).split(new string[]{“~”}, StringSplitOptions.None)

Thank,
Sunil Patel.

3 Likes

I have worked out the issue, thank you all for your help!

The For Each TypeArgument in the Properties panel is automatically set to Object. I changed this to String, and then split the item like this:

ItemSplit = item.Split({“~”},StringSplitOptions.None)

I then assigned the substrings to variables using ItemString(0) and ItemString(1)

1 Like

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