I have a scenarios where there will be multiple lines of data in Notepad.
My Flow goes line by line and validate that particular line item data.If my conditions fails in that particular line(row).I have to update the data with string manipulation and go to next line.How can i have this automated at runtime.
Can you please help with this.
Hi @JITU99 ,
Have you tried using the feature to get the text in your notepad file as a String and paste it into Excel or CSV, use it as a data table and then process each row?
You can read the data from text and then convert it into datatable using generate datatble and then you can convert back to string using output datatable and write back to text file…if in datatable its easy to edit inidividual rows in loop
The same can be acheived using loop through lines as well…but instead from text file directly reqd into string and concert it to an array of lines by splitting it on new line then iterate through do the modifications and then join back using newline again and write to text file
You can use the following solution if you don’t want to use DataTable / Excel / CSV.
NotepadAutomation.zip (83.1 KB)
Please mark as “Solution”, if you found this helpful.
You can read you txt file as arrays of strings then use for each to go through each row.
To update the line you can use assign activity inside the for each
Finally you can save the text back to txt file:
arrayLines = File.ReadAllLines(“your_file.txt”)
Write Text File:
Read Text File ‘yourfile.txt’ → Output to strNotepadContent
Assign arrLines = strNotepadContent.Split(Environment.NewLine.ToArray(), StringSplitOptions.RemoveEmptyEntries)
For Each item in arrLines
If NOT ‘condition’ Then
‘Perform string manipulation’
Assign arrLines(index) = ‘manipulated string’
Assign strUpdatedContent = String.Join(Environment.NewLine, arrLines)
Write Text File ‘yourfile.txt’ or ‘newfile.txt’ → Input from strUpdatedContent
Hope this helps