Finding Similarsentence

Hi Team,

say i have following sentence:

The cost of x in Rs 200
The cost of x in Eu 10
The cost of y in Rs 10000

if i had this data in text file how can i filter sentences having text like The cost of x in Rs , like if i had 5 sentences with Rs in it, i need to filter the 5 sentences in text file and paste it another file…

i have done similar use case scenario for words using groupby, but i feel the same logic will not apply here… pls help

i have use following code to perform the same, but not working

Arr_SortedData.Where(Function(line) line.Contains(Crit1)).ToArray()

where crit1 = The cost of x in Rs

Hi @devasaiprasad_K

=> Use Read Text File activity to read the text file and store the output in a variable say content

=> Use the below code in Assign activity:

filteredSentences = String.Join(Environment.NewLine, content.Split(New String() {Environment.NewLine}, StringSplitOptions.None).Where(Function(sentence) sentence.Contains("The cost of x in Rs")))

=> Use Write Text File activity to write filteredSentences back to new notepad file.

Hope it helps!!

Hi @devasaiprasad_K

Try this

filteredLines = str_Input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(Function(line) line.Contains("Rs")).ToArray()
String.Join(Environment.NewLine, filteredLines)

Input:

Output:

Regards,

instead both codes had worked, but i also used the same syntax, but it did not work… as i have splitted 1st and then applied filter condition… any idea on why my syntax has not worked.

@devasaiprasad_K

Can you show us the code what you have done

Regards,

i got the issue, i am passing variable, when i am passing variable its not working, but when i am passing as text in doublke quote its working…

in_SortedData.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(Function(line) line.Contains(Crit1)).ToArray()

Crit1 is a variable

why so?

@devasaiprasad_K

Can you try to delete that Crit1 variable and reassign it then try, If possible can you share your xaml

It is working in my pc

str_Input.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Where(Function(line) line.Contains(Crit1)).ToArray()

Output:

Regards,

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