'how to read text from notepad and save it to excel file in UiPath

Input from notepad: Name : Vineet Id : 123 City : Nod Name : XYZ Id : 987 City : ABC

Output I want: Name Id City Vineet 123 Nod XYZ 987 ABC

Output I 'am getting: Name Vineet Id 123 City Nod Name XYZ Id 987 City ABC

How solve this issue in Uipath ?



Solution 1:[1]

It's a bit hard to tell by how your question has formatted but the comment states you want to create a DataTable. I'm also assuming the data is written exactly as it appears in the question: "Name : Vineet Id : 123 City : Nod Name : XYZ Id : 987 City : ABC"

  1. Read Text File. Output Result will be a string. enter image description here

  2. Build Data Table - Output is DataTable enter image description here

Set the Headers to your requirements.

  1. Then do some formatting so Split into an Array

    formatNotepad = notepadOutput.Replace(" :", ":")

    personnelList = Split(formatNotepad, "Name:")

  2. Use a For Each (set Argument type to String) Worth adding a IsNullOrEmpty step as the first row will be blank due to how the Split was done at Step 3.

Then use a Multi Assign to split the "Item" and obtain the details by getting the Index of the Array.

Then use the "Add Data Row" Activity

enter image description here

  1. Write Range using the DataTable

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1