2

Just learning python on my own as I'm working. I have a column of street names where some are two words or three words, so counting spaces from the left to the right is outputting incorrectly for me. I only need to know what the very last word in the line is of data in my column, e.g., Forest Acres Circle, Main St, Bracker Road West. I tried using STREETNAME!.split(" ",2)[-1] but with the count of words it is not outputting the correct information.

3
  • just a tip: you should try using the address library and it's AddressParser module. It will parse the street type, return a list and remove any guesswork about which word means what.
    – atxgis
    Commented Mar 5, 2018 at 18:46
  • New to Arc and learning as I go, can you recommend a place to ready up on the Address Parser module and Address library
    – user110219
    Commented Mar 6, 2018 at 16:09
  • I would recommend downloading pycharm IDE. It has a newbie friendly interface for installing libraries. Thats how I got address
    – atxgis
    Commented Mar 6, 2018 at 16:34

1 Answer 1

4

As long as all your fields are space delimited, you can use this to split out your last word:

a.split(" ")[-1].strip()

In your example, Forest Acres Circle would return "Circle"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.