For each in for each

Hi,
I need to get the number of lines in PDF and for each line i should split the word and write to an excel.
using pdf.Split({Environment.NewLine}, StringSplitOptions.None).Count.ToString i had got the number of lines in pdf, then using kry.Split(" "c).Count.ToString i had got the number of words in a line. Now how would i loop for every sentence in the variable so that i could split each word in each sentence and write it in excel for splitting i am using Split( pdf.ToString, Environment.NewLine)( counter). Could anyone help me

1 Like

@soumi_soumiya - I hope the sentences must be separated by . (dots) . You can use that to separate and group words of one sentence and store to a variable.

1 Like

Hi hope these steps could help you resolve this
—initially use a build datatable activity and create a datatable with a set columns we need and get the output with a variable named dt
—once after getting the string variable from pdf as a output variable named str_output use a FOR EACH loop and mention this as a input
str_output.Split(Environment.Newline.ToArray(),Stringsplitoptions.RemoveEmptyEntries)
And change the type argument in the property panel of for each loop as string
—and inside loop use a assign activity like this
Str_variable1 = item.Split(“your keyword”)(0).ToString
Str_variable2 = item.Split(“your keyword”)(1).ToString
Like we can use string variables to store them

Or we can use FOR EACH loop inside this for each loop where mention the input as item.ToString and change the variable name in this inner for each loop from item to splitteditem for avoiding confusion
—now use add Datarow activity and mention the array row property as splitteditem.ToArray() and mention the datatable as dt
so that it will be added to the dt datatable
Then this can be mentioned in write range activity as input

Cheers @soumi_soumiya

2 Likes

Thanks Palaniyappan,
But i need to pass the words and sentence as a variable for splitting ie
Split( pdf.ToString, Environment.NewLine)( counter), counter is the variable that i had assigned but it need to incremented till number of lines in para. but my counter is not incrementing i dont know why. Is there any other way

Hi @soumi_soumiya,

1.At first you split the string using newline, then you got an array the length of the is the Number of lines…

2.You can increment the counter you mentioned as below every time in the sequence…

Capture1

Cheers.
Vashisht.