Divide and trigger data

i have a string which can have more than 300 records
In this case, i need to split the record and each record should be maximum 300
and then these 300 records needs to be inputted to a website
but everytime only 300 should be inputted and innext iteration again 300 and so on
How to achieve it?

@Shilpa_Mohanty

which ever is your split character you can use that but the code remains same

str.Split({"YourSplitWordOrCharacter"},StringSplitOptions.None).Chunk(300)

this will give 300 each in used as input for for loop

cheers

1 Like

@Shilpa_Mohanty,

Please share an example string to understand the record string.

I have string like - “1”,“2”,“4”,…
what would be the character here?
and getting error as
chunks is not a member of system.array

str = “1”,“2”,“3”,…
it would be like this

@Shilpa_Mohanty

try this a small correction remove s in chunks

str.Trim(""""c).Split({""","""},StringSplitOptions.None).Chunk(300)

trim to remove doubles quotes at end

and split on ","

cheers

CHunk is not member of system.array
errror

@Shilpa_Mohanty

May I know what version of UiPath studio you are on?

23.4+ it would wotk

if on less then need to add a counter in loop and use str.Trim(""""c).Split({""","""},StringSplitOptions.None).Skip(counter*300).Take(300)

we can use loop counter as counter here and this to be used inside the loop and the loop would end when counter > countofitems

cheers

2022.4 is ther version
i need it urgently
could you help

@Shilpa_Mohanty

please follow thsi way in loop

cheers

1 Like

counter should be initialized to 1?

@Shilpa_Mohanty

to 0

you can use the index property in loop if using for or while

cheers

and assign activity
the to part = string or list?


error that i am getting

@Shilpa_Mohanty

if you use .ToList at the end it becomes list of strings

cheers

(in_Wonum_Str.Trim(“”““c).Split({””“,”“”},StringSplitOptions.None).Skip(counter*300).Take(300)).toList

this logic gives me 0 data

You can’t trim away your double quotes and then split by them. Change this Split({””“,”“”} to Split({”,“} if you trim before you split.

@Shilpa_Mohanty

Can you firs check if split is giving any data

you can do a count after split to know count of items

better show a screenshot of the data from locals panel

cheers

here is sample data

@Shilpa_Mohanty

Please split with comma…remove two double quotes from eachside {","}

also trim can be removed

cheers