on 06-10-2022 3:08 PM
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.-
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.