Textdata1

Hi friends,
I have some data in one .txt file and in another .txt file I have some more data.
The first text file has 5points and the 2nd text file also has 5points.

I need to check if the 1st point in the 1st text file is similar to any of the 5points in the 2nd text file.

Example
1st text file is named as BPL1

  1. Draft at sight in the name of ABC and will be given to CDF
  2. Manually signed
  3. Full set signed
  4. Packing list
  5. Certification of original

2nd text file is named as BPL2

  1. Full set signed
  2. Manually signed
  3. Certification of original
  4. Packing list
  5. Draft at sight in the name of ABC and will be given to CDF

So I need to check if 1st point that is Draft at sight is available in BPL2 and if available I need to write yes next to that point in BPL2.

I really don’t know how to do this. Can anyone help me

@hanviprebday

Assign activity:

linesTextFile1 = textFile1Content.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)

Assign activity:

linesTextFile2 = textFile2Content.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)

For Each activity (For Each item in linesTextFile1):
Assign activity:
isMatch = linesTextFile2.Any(Function(line) line.Trim().Equals(item.Trim(), StringComparison.OrdinalIgnoreCase))

If activity:

isMatch = True
Assign activity:
index = Array.IndexOf(linesTextFile2, item)
linesTextFile2(index) = item & " - Yes"

End If
End For Each

Assign activity:

updatedTextFile2Content = String.Join(Environment.NewLine, linesTextFile2)

cheers!!!

Hi @hanviprebday

Please find the solution attached below.
TEST1.zip (2.9 KB)

I hope it helps.

Cheers!

@sai_gupta
I am not able to open the test file.can you please write the activities and tell me

@Gayathri_Ramanathan I am getting error at this assign

isMatch = linesTextFile2.Any(Function(line) line.Trim().Equals(item.Trim(), StringComparison.OrdinalIgnoreCase))
The error is option strict on disallows late binding

What should I do

Hi @hanviprebday

Please try the below according to the image

Output of Text1.txt is strText1
Output of Text2.txt is strText2

Assign values:

arrText1 = Split(strText1.Trim,vbLf)
arrText2 = Split(strText2.Trim,vbLf)

arrText1 & arrText2 are of datatype array of string → String

If condition:

arrText2.AsEnumerable().Select(Function(y) y.Trim).Contains(item.Trim)

Assign Values below:

intIndex = arrText2.ToList().FindIndex(Function(x) x.Trim.Equals(item.Trim))

arrText2(intIndex) = arrText2(intIndex).Trim + " - Yes"

Please print the below line in the msg box to check the output

String.Join(“,”,arrText2)

Hi @hanviprebday

  1. Read Both Text File

BPL1 as String
BPL2 as String

  1. Use Assign Activity

arrayBPL1 (Array of String)= BPL1.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries)

arrayBPL2 (Array of String)= BPL2.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries)

  1. Use For Each Activity (List of Items=arrayBPL2)

  2. Use If activity in the for each
    Condition: currentItem.Trim.Equals(arrayBPL1(0).Trim)
    Then
    4A. Use Invoke Method Activity for adding, and in the Parameters put like this currentItem+" Yes"

    Else
    4B. Use Invoke method for adding only

After the For each Use Assign activty and create a variable called FinalText

  1. FinalText= String.Join(Environment.NewLine,BPL2List)

  2. Use Write Txt File activity for writing into it

Hope this solution helps you
Forum.zip (744.8 KB)