Read from .txt file

Hi, Team!

I have a .txt file and I want to keep from it only the lines that contain " Pc ".
Can you help me please?

3,0 770331208 500 Pc 418,60 1.883,70
Union flat seat Index 32,20
331 11/2. G Multi 13,00
Discount -10,00%

4,0 770245235 100 Pc 642,20 577,98
Hexagon nipple, reducing Index 49,40
245 21/2.2. G Multi 13,00
Discount -10,00%

Thanks,

1 Like

Hi @LZlz,

Read text file, split the string output by Environment.newline,
iterate the array, use IF loop(item.contains(“Pc”)) Then store it in a collection/array or concat in string variable.

Thank You,
Shubham Pratap

1 Like

Hi,

Can you try the following steps?

  1. Read text file to string variable (let’s say strData) using Read Text File Activity.

  2. Use Assign activity with the following expression

    strData = String.Join(vbCrLf,strData.Split(vbcrlf.ToCharArray,StringSplitoptions.RemoveEmptyEntries).Where(function(x) x.Contains("Pc")))
    
  3. Write strData to text file using Write Text File Activity if necessary.

Regards,

1 Like

Thank you very much for your contribution.
Your opinions helped me a lot!

1 Like

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