Part operator syntax:
This is a special operator for fields that is called: "part".
This operator allows you to:
The interface (GUI) of Benetl provides a function called "part formula viewer".
It helps you to define and test your "part formula" by giving you the result according to the datasource line to be read.
Click on the "part" formula and then press enter. It will then open the part formula viewer.
The "part" operator has a special syntax:
In order to retrieve a sub-string from the value of the current field, you can use the word "regex".
Do not use "." character in the regex syntax because the "." character is used to concat sub-string here.
Instead of "." please use "\W\w" which can retrieve any alphanum character.
In order to retrieve a sub-string from the filename, you can use the word "filename".
First number is the start position and second number is the end position of the sub-string from datasource file name.
In order to add a string to the value of the current field you can use "." character.
Example: . bonjour
This will add " bonjour" to the value of the field of each lines of the datasource file read.
If you need to use a value from a previously parsed field you can use the word "field".
This word is followed by the number of the field.
In this example we are adding "01/" to the value of the field number 3, then we add "/" and the value of the field number 17.
This example was retrieving a date: field3 was month and field17 was a year.
A much more complex example is combining several words of "part" syntax:
This example was retrieving the day (position 19 to 21), the month (position 17 to 19), the year (position 13 to 17) from the datasource filename. It is also retrieving hours from the current field value, with a regular expression. It is also adding ":00:00" wich is meaning 0 minute 0 second.
All of this is retrieving a complete date: 29/12/2007 3:00:00, which is corresponding to a french date format.
line_number will add the number of the line read to the formula.
With interval it will possible to add or remove a timestamp interval from your dates.
It has to be used with a "date" field. The interval function must be in the last position of a "part formula" .
— interval ’1 month’
+interval ’2 month’
Note: no spaces between +/- interval and ’x month’.
Benetl 2.2 supports 23 mathematics functions you can use and combine into a same "." part of your "part formula":
Examples of combination:
for these functions the argument separator is ";" and "," is used for floats. French localized users must use "," as float here because "." is used as a concat operator in "part formula".
if you don’t mention a field in functionnalities with unique argument, then the current field is used.
these mathematics functionalities (inv, abs, min, max, avg, plus, minus, divide, multiply, dist, round, ceil, floor, square, pow, exp, log, asin, sin, acos, cos, atan, tan) can not be used with "regex", "filename", "interval", "lowercase", "uppercase", "line_number" inside a same part "." of the "part formula".
Benetl 2.7 adds 4 new functions:
Benetl 2.8 adds a new function:
Example of substr use:
Benetl 3.5 adds a new function:
if(fieldX contains ben;ben;fieldX)
Benetl 4.1 adds to this function:
The first argument is the condition. The second argument is used if the condition is true. The third argument is used if the condition is false. You can use "if" function with the mathematics functions described above.
Benetl 4.5 adds fact function: