Hi Community,
I got a requirement where I need to upload a text file and after uploading will check for particular keywords in uploaded file (keywords like: Name, Id,etc).
If any of these keywords matches then will store that file data in database in their respected columns.
I am uploading the file and reading the data but I am unable to search with a particular keyword and store it.
Can someone from the community help me in achieving this requirement.
I have even shared the .oml file and .txt file.
Thanks in advance.
Regards,
Vin J.
Hi,
As you mentioned "I am uploading the file and reading the data but I am unable to search with a particular keyword and store it. ".
So how you are reading the content? If content in plain text then can we hold the value in any variable and perform string operations to find the match.
regards
Hi Vikas,
I am reading the file with binary to text server action.
String operations means exactly what?
Vin J
Hi Vin,
You can use regex to search in the string for the format you want
https://success.outsystems.com/documentation/how_to_guides/logic/how_to_use_regular_expressions_in_outsystems/
https://regex-generator.olafneumann.org/?sampleText=2020-03-12T13%3A34%3A56.123Z%20INFO%20%20%5Borg.example.Class%5D%3A%20This%20is%20a%20%23simple%20%23logline%20containing%20a%20%27value%27.&flags=i
Hope that it helps you
As suggested by Alex, you can use regex or you can use built in method index of string. It will return index value. If its -1 means not found otherwise found.
I have already used index string of but it’s not searching those letters or words.
You can check it in .oml file that I have shared.
Hello @Vin J,
The condition where you are comparing the text with the file content is not correct. You had concatenating 2 string without any space (Index(BinaryDataToText.Text, "Name" + "Change") > -1) and trying to search into the file content where as in your file there is only string "name" not "namechange". So, it not matching the going into the "Not Found" condition.
Please try with this condition and it will work for you. If you would like to go with fuzzy search then use regular expression which will match the words.
Index(BinaryDataToText.Text, "Name") > -1
Thanks,
Sachin
Hi Sachin,
I have tried that but still it is showing "Not Found".
Can you please update it once in the .oml file and check so that you will also get clear understanding.
Regex is really a bitter fit you are trying to match with more then one keyword. And when you want to have exclusion sets (like has the word "storm" and "fire" but not "smoke") then regex is really your only option.
To get you started.
The following regex "change|name|catchy"
will match the words "change", "name" and "catchy" in the following sentence: Lets change the name of the product to something more catchy. To know how to use regex you can read the documentation or use some tooling. I can recommend RegexBuddy or, if you don't want to learn regex, RegexMagic (same author). His documentation about regex is also one of the best. You can find that here: https://www.regexbuddy.com/regex.html.
Hi Vincent,
Thank you for replying using regex expression we get the words but my requirement is like after getting the words the values must get stored in database not the words or the whole file data.
Like you can check in the .txt file that I have uploaded.
This is still possible. In the textprocessing component you can use the RegexMatchAll action. This will return all texts that where matched. So in my example ("change|name|catchy") it will return "Change" and "Name" in the following sentence "Lets change the name so it will catch more traction".
There is also an component with a similar name TextProcessing (really, who made this up?) that has an similar action with the same capability.
Can you help me by doing this in the .oml file that I have shared.
I will be a great help for me.
No sorry, I simply do not have the time to do this. I'm sure you will be able to figure it out yourself when you take a look at it. It is really straight forward.
Ok Sure