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.
-
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.– atxgisCommented 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– user110219Commented 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– atxgisCommented Mar 6, 2018 at 16:34
Add a comment
|
1 Answer
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"