fstony

ERROR 000539: SyntaxError from field calculator

Discussion created by fstony on Oct 31, 2012
Latest reply on Nov 2, 2012 by curtvprice
I want to parse a text field into a floating point field. (e.g.: "10-Inches Bituminous Concrete 8-Inches Portland Cement Concrete 6-Inches Crushed Stone Base" becomes "10")

Expression:
theBottom(!Description!)

CodeBlock:
def theBottom(desc):
  num = desc.find("-")
  if num < 0:
    return 0
  else:
    return float(desc[0:num])


Originally, I wanted to use multiple input fields in the expression, but I can't even get this bit to work. It gives this error: "ERROR 000539: SyntaxError: EOL while scanning string literal (<expression>, line 1)"

Any suggestions?

Outcomes