Closed mapface closed 1 year ago
@mapface < can you try giving the expression in double quotes
Hi @vijaygit02
Double quotes gives a syntax error for me -
ERROR 000539: File "
", line 1 "todate(u"Example_202205160903_1b_XY_Test")" ^ SyntaxError: invalid syntax
@mapface , can you share your mdcs config file
Hi @vijaygit02 - attached
I had the same issue. Solved it by typing pure python code without the newline character. Looks a bit messy now since the line intent does not fit to the XML Tag anymore.
<CalculateValues>
<CalculateValue>
<query>#</query>
<fieldName>GroupName</fieldName>
<expression>splitLayerName(!Name!)</expression>
<expression_type>PYTHON3</expression_type>
<code_block>import re
def splitLayerName(value):
mo = re.search('^dtk(25|50|100)[_]\d{4,5}[_]\d{4}[_]\d+[_][a-z]{2}|^[lc]?\d{4}', value.lower())
try:
return mo.group()
except AttributeError:
return None
</code_block>
</CalculateValue>
</CalculateValues>
Hi @resQm3 that appears to have done the trick, ran the process successfully.
@resQm3 , thanks for the solution. @mapface , I'll close the issue.
Having issues in making codeblocks work for the calculate value tool - followed the master.xml template but keep getting a Name Error:
Results in:
Can confirm same codeblock works in ArcPro calculate field. Any advice?