If you are struggling on the field calculator of gvSIG because it lacks some chunk of code that would make your life easier, maybe you will find this interesting. On the field calculator you can evaluate external python scripts to add new functions to it. It’s easy, just type on a new text file something quite self-explanatory like this (if you know the minimum basics of Python language):
def mysplit(myString, splitChar, position): try: val = myString.split(splitChar)[position - 1] except: val = -999 return val
Then on the second tab of the calculator, locate your file and click on the “Evaluate” button. If no errors are reported then you can use your mysplit function on the field calculator in the same way you use the built-in ones. In my case I used this to parse a field with the typical “X,Y,Z” centroids that I couldn’t parse with subString because they had different lengths so the Python string split was so convenient. This was as easy as just typing on the calculator to get the first coordinate:
toNumber(mySplit([LONGFIELD],",",1))
Easy, isn’t it?
Everything is very open with a very clear description of the challenges.
It was definitely informative. Your website is very useful.
Thanks for sharing!