Hello.
The IQ Bot of Automation Anywhere introduced in this article yesterday ...
Since the version 11.3.3, for the read result, You can now do a little processing using a programming language called Python.
In Automation Anywhere terminology, this is called "custom logic."
According to the information as of April 3, 2020 I can't use custom logic with the IQ Bot that comes with the cloud version of A2019, It can be used with A2019 on-premise and V11 series version.
When do you use custom logic in the first place?
There are various answers to the question, but here are some examples.
pattern | Concrete example |
---|---|
Fixed garbled characters with fixed patterns | -Fixed the Tokyo thorn problem (there is an OCR that Tokyo is read as "thorn") -Fixed the problem that the "day" of YY MM month DD day is changed to B or 0 (this also has OCR) |
Extract only the desired element from the reading result | ・ Extract only 123 of the amount from "Payment amount will be 123 yen" ・ Extract only the branch name from "Ai Bank Kakiku Branch" ・ Extract only the unit mg from 1000 mg |
Fixed value substitution | If the value is uniquely determined for the group (*), a fixed value will be entered. |
Apply format | YYYY MM month DD day YYYY/MM/Change to DD |
If you simply read the result with OCR, it will be too dirty to use as data for subsequent processing ...
In that case, if you play with the custom logic a little, you can get beautiful data.
The usage of field items and table items is slightly different, so I will explain each.
Custom logic can be written in the IQ Bot's Mapping Settings screen (https://qiita.com/IQ_Bocchi/items/2c5a6e77d6059b968a74). Click the tab labeled "JA-JP: LOGIC" in the figure below ... (* If there is no tab when you open the screen / IQ_Bocchi / items / b75d84be6784f5fd51fb # 2-% E3% 82% AB% E3% 82% B9% E3% 82% BF% E3% 83% A0% E3% 83% AD% E3% 82% B8% E3% 83% 83% E3% 82% AF% E3% 81% AE% E6% 9C% 89% E5% 8A% B9% E5% 8C% 96)
We will define the logic with this ↓.
For field items, you can apply custom logic to each item.
Since the read raw value is in a variable called field_value
, we will play with it and process it.
Example of applying custom logic to field items: For fixed value assignment
field_value = "Value you want to assign"
It's like this.
Field items are fairly simple because they are simple string operations. I would like to release a convenient copy code one after another.
In the case of table items, there is no logic input field even if you look at each item.
Instead, you can set the logic from here ↓ in the area where you want to set the entire table.
Open the above "Ja-JP: Logic" and write the logic like this ↓.
For table items, the contents of the entire table are contained in a variable called table_value
.
This table_value
is in a special type called a dataframe, and I have a little promise when dealing with it.
Here is it ↓
How to write custom logic for table items
#Code that must be entered when operating the table (first)
import pandas as pd
df = pd.DataFrame(table_values)
#
#In the middle part, put the code you want to process
#
#Code that must be entered when operating the table (last)
table_values = df.to_dict()
I personally read the above code as "magical code".
What the magic code is doing I also wrote Explanatory article for those who are interested,
As long as you keep in mind that "when processing table items, add magical code at the beginning and end" You can skip the above article.
For table items, there is a little promise in the processing code part, People who are not accustomed to Pandas (*) often get lost.
python
#* I confess. That's me ...
That's why, for a while in my Qiita content, Useful codes around table items (those who touched IQ Bot and got lost or searched) I will introduce it!
--With IQ Bot, you can create quality data that can withstand subsequent automatic processing by processing the read result with custom logic.
--Custom logic can be applied to field items and table items differently.
--In the case of a field item, it's easy because it only processes the raw reading result stored in the variable field_value
.
--In the case of table items, the entire table stored as a data frame in the variable table_value
is processed, so it may be a little hurdle for those who are not familiar with Pandas.
――That's why, in the future, we will publish a cheat sheet of custom logic for table items.
Then!
Recommended Posts