I am relatively new to UIPATH. In our company, we create invoice files from AS400. The invoices are in text format. Using the text reading functionalities available in UIPATH, we are able to get the complete text.
But we are struggling to extract relevant data from the text file. What is the best way to distinguish and segregate useful data like date of invoice, company name and Invoice amount etc. We tried to use anchor base but it did not work as expected.
Please let me know where to write the custom code in UIPATH and once we find the relevant keyword like Invoice Amount, how to read the value next to that (The actual invoice amount) ?
I think I am trying to do the same thing as the person that asked this question. I am trying to pull the text table out of an invoice into an excel file. I have many files all with the same format and would ideally like to go through all of them without opening them. I have just downloaded UIpath so I am still orientating myself.
My item.Contains(“TOTAL”) doesn’t output anything, I am trying to get the total which is to the right of this word. I write putting a “write text file” block after with the “item” variable but I get nothing out.
Ideally I want to get the items in the table and the total at the bottom and then put it into an excel sheet.
If you use the .Split function you can break it up
For example,
fulltext.Split({“TOTAL”},System.StringSplitOptions.RemoveEmptyEntries)(1).Split(System.Environment.Newline(0))(0).Trim
So that will take the 2nd item after you split by the word Total and split again by newline character, which in return will give you the text next to the word Total. And no loop needed.
You can similarly break up the text into an array of line items for which you can process.
Additionally, if you format the text into a CSV format with comma delimiter then you can use Write Text File with .CSV extension, and read it back into a datatable with Read CSV… that is if you choose to.
I have text in this format.
Source Id
123455
Destination
1234456.
How can i extract data (123455) which is in next line after the keyword (Source Id).I didn’t get your previous explanation.Can you eloborate on that?
If you use only the following, Str.Split({“Source Id"},System.StringSplitOptions.RemoveEmptyEntries)(1) it will give output as,
123455
Destination
1234456
Because it splits based on the word Source Id where first index i.e 0th index will have a empty/null value and 1st index will have our output mentioned above(italicized).
Again if you make the following operation in that output, .Split(System.Environment.Newline(0))(0)
It will return 123455
Because splitting based on newline will give 3 elements while accessing the first one 0th index gives our output(italicized).
Note thus Clayton has used the whole code to get it in a shot.
@sreekanth, as we get are accessing only the first index which is nothing but a string then you have to change the type from string array to string. And in error it was clearly mentioned.
Hi @SHAISTA,
Use screen scraping and assing values to variables.Then build a datatable and add data row using variables.Then you can write the datatable to excel .If you have multiple pdf’s use open application activity and pass your pdf reader.exe in it.