Delete lines from Notepad where Line contains specific data

Delete lines from Notepad where Line contains specific data

Use Case Description

I want to Delete the Text File line where the line contains a specific value.

AS-IS WORKFLOW, TO-BE WORKFLOW

Capture.JPG

Other information about the use case

Industry categories for this use case: Information Technology and Services

Skill level required: Intermediate

UiPath Products that were used: UiPath Studio

Other applications that were used: Notepad

Other resources: -

What is the top ROI driver for this use case?: Improve customer experience

Hi @faheem14

Read the data using read text file

then split the output on Environment.Newline

Then loop through each item and check for required keyword using if condition item.contains(“requireddata”). on false side , Add the line to a separate array

then join the array back using string.join function and write data back to excel

Else use the expression directly

String.Join(Environment.NewLine,str.Split(Environment.NewLine,StringSplitOptions.None).Where(function(x) Not x.Contains(“RequiredString”)).ToArray)

str is the output from read text file
Requiredstring is what you are searching for

Use assign and assign this back to str

write str back to text file

cheers

@Anil_G Thank you so much it worked.

1 Like

HI @faheem14

Happy Automation

Can you please close the topic by marking solutions so that others with similar query can get help

cheers