cancel
Showing results for 
Search instead for 
Did you mean: 

IRPA 2.0 - How can I get some values from a txt file and validate them?

carina0101
Participant

Hi IRPA Team

We need to read a txt file and get some values and then validate them. It seems to me that there aren´t SDK activities for this type of file, so I thought I'd make a custom script... but I don't know how to continue it... Is there any other way to do it?

As can you see in the print screen attached txt-file-analize.png, we need:

(1) Get the value of the 2nd line and validate that it´s equal to G3040..

(2) Get the value of the 2nd line and validate that it´s equal to a part of the file name.

(3) Get the total number of columns (or characters) for each line starting with D000...and verify that the total number of columns is equal to 52

(4) For each line starting with D000..verify that the column from 45 to 48 it´s equal to 2022.

Could you help me?

Best, Carina.-

carina0101
Participant
0 Kudos

Hi chaitanyapriya.puvvada

Please, could you help us? Is it posible to do with IRPA?Wich activities (and expressions into them) should we use in automation flow to solve it?
Best, Carina.-

Accepted Solutions (1)

Accepted Solutions (1)

vishal
Contributor
0 Kudos

Hi carina0101,

Based on earlier comments - below is high level design template I suggest

(Click on Attachment links at bottom of post - to enlarge them for clarity)

(Click on Attachment links at bottom of post - to enlarge them for clarity)

Have explained few of the requirements but have considered the toughest ones.

You can use above as a baseline, refer to given suggestions to further build on top of it, customize and test to achieve required automation results. All the best !!

Regards,

Vishal Rathi

carina0101
Participant
0 Kudos

Hi vishalrathi21

Thanks a million!!

I could see how read each item of file. Also the expresions sent allowed me undertand how make the rest of validations.

Best, Carina.-

Answers (1)

Answers (1)

vishal
Contributor

Hello carina0101,

As there is need to compare file name with content of file (2nd line), first we need to maintain file name in a separate variable. Either you hardcode it in a variable (if its constant file name), else you use the “Get File Name” activity to dynamically fetch the file name during bot execution and store it in a variable (say VarFileName)

Once you have stored the file name and also get the output of file text, you use a For Each loop to browse through each row of the file and save the output in a list.

From that point onwards, use For Each activity to call out each item from the list (row in your file) and carry out the validations (can club one or more of below in For Each activity as much possible to make it more efficient, however I suggest you start simple with having one For Each for each task below)

Ex.

  1. call 2nd item and pick first 5 chars using custom script and compare if its equal to G3040
  2. call 2nd item and pick 6th to 8th char using custom script, also obtain file name from VarFileName – collect 7th to 9th chars and compare both values if matching
  3. pass each item in a for each loop and set flag to a variable on how many items begin with D000,
  4. another for each loop to pass the D000 rows to count number of chars in the line if equal to 52,
  5. another for each loop to pass the D000 rows to identify if char 45 to 48 is equal to 2022

PS: There will be a bit of custom code required only for some string operations like - to pick specific characters of the each item/row (like first 5 chars of line 2, first 4 chars of line 3 onwards, char number 6th to 8th to compare with file name and so on). These can be achieved by using very useful and simple JavaScript string methods detailed here

Hope this outline helps setup your automation use case.

Regards,

Vishal Rathi

vishal
Contributor
0 Kudos

Another alternate option would be to move the content of file to excel (can store each character in one cell) if you are comfortable in handling excel file related operations. However I would suggest you try previously explained steps first and jump to excel option only if any roadblock encountered

carina0101
Participant
0 Kudos

Hi vishalrathi21

Thanks a lot for your answer, I understand your advice and proposed logic, but we need to see some example that how to do it . Wich activities (and expressions into them) we should use in automation flow to solve the items 3 and 4.

Best, Carina.-

lucie16
Active Participant
0 Kudos

Hi Carina,

I am just adding, that in custom script you use javascript. So you can google the syntax 😉

Regards

Lucie

carina0101
Participant
0 Kudos

Hi lucie16

Thank you for your comment.

Best, Carina.-