1

I'm trying to split a field of street addresses (field name "PROP_STREE") so that it returns only the house number (so "123 Main St" would become "123").

Following the solution provided Field Calculator: Split address into house number, street name, I am using the following script:

def addressParser(inString):
  splitString = str(inString).split(' ')
  houseNumber = splitString[0]
  return houseNumber

PROP_NUM = addressParser(!PROP_STREE!)

But it keeps returning "Failed to execute. Parameters are not valid. ERROR 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 6)."

What mistake am I making in my code?

Here's what the Field Calculator window looks like, for reference.

enter image description here

I'm using ArcGIS 10.6.1.

closed as off-topic by BERA, Fran Raga, Vince, LaughU, Ian Turton Jun 11 at 8:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This problem cannot or can no longer be reproduced. Changes to the system or to the asker's circumstances may have rendered the question obsolete, or the question does not include a procedure to enable potential answerers to reproduce the same symptoms. Such questions are off-topic as they are unlikely to help future readers, but editing them to include more details can lead to re-opening." – BERA, Fran Raga, Vince, LaughU, Ian Turton
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Check code block option and call function from box below. – FelixIP Jun 9 at 19:27
  • 1
    Adding to what FelixIP has said, maybe you can specify that inString is actually a string, such that str(inString).split(' ') – Daniel Jun 9 at 19:33
  • 1
    Replace picture in your post with latest. desktop.arcgis.com/en/arcmap/10.3/manage-data/tables/… – FelixIP Jun 9 at 19:41
  • 1
    When you split, you get a list of two elements, if you write str(inString.split(' ')) of course it will raise an error. Try it as I wrote it. In the midtime, let me check what you have written about addressParser – Daniel Jun 9 at 19:42
  • 2
    It means that field NUM is numeric and you have house numbers like 24B. Create new field, make sure it is text. Can be done without block !stree!.split(" ")[0] – FelixIP Jun 9 at 20:05