cancel
Showing results for 
Search instead for 
Did you mean: 

How to give dynamic input value in read all text from file?

JamunaT
Level 4
I need to process the each text file which is in different name inside the folder,
So that just used GET FILE action to get the all files inside the folder then used loop & passed GET FILE output collection into the loop.   
Now I need to know how to give dynamic File Name in the input filed for READ ALL TEXT FROM FILE action after loop.
Because text file name is differ in both text file , when one txt file process completed the loop will take to process next file so reading the text file ,name will change every loop.
I just tried with "*.txt" in the input field but its not reading the text file .
I have attached the screen shot as per my try kindly refer it and also guide me correct way like how to give the dynamic input for READ ALL TEXT FROM FILE action please,

769.png
In Patterns CSV , I have given "*txt"  I am not sure , is this correct way , Kindly clarify this also.

770.png

771.png

Thanks in advance.

------------------------------
Jamuna T
Changepond Technology
chennai
------------------------------
1 BEST ANSWER

Best Answers

Yeah, it looks like the Read Lines From File action doesn't allow you to just take whatever is in the file. You could count the lines first, but I think below is an easier way. Just use the Utility - Strings object's Split Lines action. And in the input, use LoadTextFile([Files.Path]). And Output to your collection where each line will be in a separate row.

752.png


------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------
Dave Morris 3Ci at Southern Company Atlanta, GA

View answer in original post

7 REPLIES 7

EmersonF
MVP
Hi @Jamuna T nat the  in the field File name of the action utility - file management, pass [Files.Path] this should solve.This is because the action can only read one file at a time, every time you read a file, you can add a calculation stage and add a line break or some indicator.
​​

------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
+55 (081) 98886-9544
------------------------------
Sr Cons at Avanade Brazil

DaveMorris
Level 14
Emerson answered the question already, but I notice you're using the File Management VBO to read the text from the files. There's nothing wrong with that, but I wanted to point out that you can also use the native Blue Prism function LoadTextFile() which you can use in a Calculation stage or directly in the input of some other action stage.

So to put that with Emerson's suggestion, the expression in a Calculation stage might look like this: LoadTextFile([Files.Path])

------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------
Dave Morris 3Ci at Southern Company Atlanta, GA

Thanks for the support @EmersonF & @Dave Morris  , I have used ​ [Files.Path] , Its working Fine as per expected.
I need one more Solution for Read lines from file action. In the input field I have provided start line as 0.
But I don't know the exact end line number because end line number will be differ in each text file for every loop and also each text file is having more than 1000 lines
So how to give biggest number in End line inputs field?
I have attached the screenshot below Kindly refer & guide me please this also,

739.png


------------------------------
Jamuna T
RPA developer
Changepond Technology
chennai
------------------------------

in general there are how many lines, you can leave a set value, type end line = 5000
In the start line just put 0 and not "0" because it is a number and not a string, but I believe you need it, you may be using read all text from files that it should take all the lines

------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
+55 (081) 98886-9544
------------------------------
Sr Cons at Avanade Brazil

Yeah, it looks like the Read Lines From File action doesn't allow you to just take whatever is in the file. You could count the lines first, but I think below is an easier way. Just use the Utility - Strings object's Split Lines action. And in the input, use LoadTextFile([Files.Path]). And Output to your collection where each line will be in a separate row.

752.png


------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------
Dave Morris 3Ci at Southern Company Atlanta, GA

@Dave Morris from what version is LoadTextFile () available? Could you tell?​

------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
+55 (081) 98886-9544
------------------------------
Sr Cons at Avanade Brazil

It should be available in any version that anyone's using now. I can't remember specifically but I think it was even in Blue Prism 5.

------------------------------
Dave Morris
Cano Ai
Atlanta, GA
------------------------------
Dave Morris 3Ci at Southern Company Atlanta, GA