I'm using the ArcMap Field Calculator to parse the year from a field
GLVertra_1 with values like this:
or more generally YYYY/MM/DD, but also containing empty cells (or cells appearing empty).
My approach is
JAHRNU = stringToInt( !GLVertra_1! ) with the function:
def stringToInt(s): if not s: return 0 else: return int(s[0:4])
This results in the error
invalid literal for int() with base 10:, which I assumed comes from empty strings, so I introduced the check for empty strings (
if not s), but it still doesn't work.
The answer here (automatic casting) doesn't work for me, if I don't cast it explicitly as
int(), I get an error (
The value type is incompatible with the field type)