How to write selective Data from Notepad to Word

studio

#1

I have a text file in which there is a set of structured data each with some parameters . I have to selectively take data from text file based on the 5 parameters values and then send it to word.
If those 5 parameters exist for the dataset and their values are the same ,then we have to append each dataset one after the other and send it to word. If they dont exist then we cannot append that dataset to the previous one

We are considering the parameters and its values for the 1st Datset as the criteria.

For this I tried using the split option in notepad , but didn’t get ideas post that. Thereafter I thought of shifting it to an excel file to get the data in row format and thought of building a dataTable with 2 columns ,one column of parameter and other column of Dataset but I am not getting further ideas on how to selectively find the parameter values from each row .

I want to know how can I make a loop for finding those 5 parameters with their values and stopping thereafter and appending the corresponding dataset to that and then in the 2nd iteration of the loop going down ,again finding those 5 parameters and matching their values with the 1st one and if it matches then append their dataset to the 1st dataset and going down to the next page and doing the same thing and appending the 3rd dataset to the above one and henceforth for the remaining datasets.

I have uploaded the a sample file for reference . In actual file the same parameters and its corresponding Dataset repeats with different values for around 10-15 times or may be N no. of times.


#2

Hi @abhishek26

Could you break down the process into easy steps. This is what I can guess for now:

  1. Your .txt file consists of blocks of same data that are appended on top of each other
    Solution:
    -find delimiter by which the blocks can be split into smaller chunks, maybe all new chunks start with a particular phrase, such as “Report nr X” or similar.
  2. Data to be extracted consists of 4 parameters roughly scattered above the table AND 1 full column of data from the table

And this is where I get confused a bit. Could you complete the below process flow. I will start:

  1. Load .txt file into a variable in UiPath
  2. Split string into an Array of String using a specific delimiter
  3. Loop over each element of the Array of String to do some actions
    Actions to be done for each chunk:
  • <please fill in this part>

I hope it is already helpful :slight_smile:


#3

I have already tried this approach but how to get the parameters and values of those parameters .


#4

This can be achieved with Regex search. But it will be best if you can separate the file into chunks, as Regex will find all occurrences which can get messy.

Example:
This will find the value of elevation:
https://regex101.com/r/a5wCt6/1

System.Text.RegularExpressions.Regex.Match(yourInputString,"(?<=Elevation: )\d+\.\d ft").ToString

#5

Hi Maciej,

I was able to fetch the parameter values ,thank you, but how can I extract the Dataset which I highlighted in the notepad ?


#6

If the Data Table is always with the same structure, it should be doable to find it with Regex in each chunk and then post-process the result. See example in the attachment :slight_smile:

ExtractColumn.zip (2.7 KB)

Keep in mind that I remade a simple version of your file just to present the solution.


#7

I am not able to view the full workflow,neither am I able to run the workflow as I am getting some runtime exception errors related to some XAML errors.


PFA the reqd error documents for reference


#8

Could you specify your Studio version? I suppose it is Enterprise 2018.2.*?


#9

Hey, it is 2018.2.4 . Anyways I got the required regex code for my notepad file, thanks to you :smiley: