There are two bugs within the substring implementation in python Here.
First of all, if a value is null in the field that the method is acting on, the string "None" is then used as the string to slice. The value should just remain None type.
Secondly, the slicing of the string is incorrect. In the interface it asks for the number of characters after the starting position to go up to. Within the python, it merely slices it by that number.
An example of the first bug is here:
Here you can see a source field called Unit that is blank.
Here you see that the preview shows the outcome would be one, which is a substring of the string None
Here you see the incorrectly sliced String has been added to a field that should be null
An exmple of the second bug would be the following.
At the moment, getSubstring looks this:
So if you had string "Example" starting at position 1 with the number of characters being 4, the function would return
"Example"[1:4]
Instead it should be
"Example[1:1+4]
I've implemented these changes in the following script. I would send a pull request but I'm not sure how to change the script within data assistant. If someone has a moment to show me that'd be very helpful.
dlaFieldCalculator.zip
@pLeBlanc93 @MikeMillerGIS @chris-fox
There are two bugs within the substring implementation in python Here.
First of all, if a value is null in the field that the method is acting on, the string "None" is then used as the string to slice. The value should just remain None type.
Secondly, the slicing of the string is incorrect. In the interface it asks for the number of characters after the starting position to go up to. Within the python, it merely slices it by that number.
An example of the first bug is here: Here you can see a source field called Unit that is blank. Here you see that the preview shows the outcome would be one, which is a substring of the string None Here you see the incorrectly sliced String has been added to a field that should be null
An exmple of the second bug would be the following. At the moment, getSubstring looks this:
So if you had string "Example" starting at position 1 with the number of characters being 4, the function would return
Instead it should be
I've implemented these changes in the following script. I would send a pull request but I'm not sure how to change the script within data assistant. If someone has a moment to show me that'd be very helpful. dlaFieldCalculator.zip @pLeBlanc93 @MikeMillerGIS @chris-fox