I am trying to split an attribute into its component pieces with FME.


into: 1707 WILLINGTON ST, PHILADELPHIA, PA, and 19121

I am using the AttributeSplitter using a comma Delimiter and I get this: 1707 WILLINGTON ST and PHILADELPHIA PA 19121

How do I get the state - city - ZIP in three separate fields?

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Jun 4 '15 at 21:09
  • 2
    Is the address always separated from city by a comma? If so, couldn't you just do two splits? The first using a comma delimiter as you have, then split the resulting CSZ again using space as the delimiter instead of a comma if that's allowed. – Chris W Jun 4 '15 at 21:50
  • Use AttributeSplitter with ',' and store results to _firstlist (ListName variable) ( assuming that your data contains only one ',' ) Then use AttributeSplitter ' ' from list{1} to _secondlist – simplexio Jun 5 '15 at 7:07
  • Could you rely on just getting the ZIP code (last 5 chars) and using a zip code lookup to get State and City? You then only have the street to deal with. – James4571 Jun 5 '15 at 9:26
  • The data contains "," in most of the rows, what you suggested guys works, except for those with double ",". I split the line in twice first, then Rename the left as STREET, then I split the right part using a space and renamed it as ZIP, STATE AND CITY. The problem is here: 007, 700 S 13TH ST, PHILADELPHIA PA 19147 – Fflavioo Jun 5 '15 at 14:15

In FME 2015.1 (used here)

Use the SubStringExtractor

enter image description here

If you need to work out the number of characters for the substringExtractor then use the StringSearcher it will have matched_characters you can use this as parameter for extracting multiple addresses.

  • 1
    Since the address and city could be potentially variable length strings, is character location the best approach? In theory the zip and state will always be five and two character strings, respectively. I would think if there were a way to use that tool to break off substrings at the space starting from the end, that would be easier than working out numbers of characters. But I don't know FME at all, so the other things you mention may address this. – Chris W Jun 4 '15 at 21:48
  • The basic idea is to create a parameter for STREET etc with x number of characters then loop that number into the stream for the next row. – Mapperz Jun 5 '15 at 2:59
  • Thank You, I tried that to explode my list into unique characters: 1305 / N / HOPE / ST / PHILADELPHIA / PA / 19122 /. The problem is that my rows don't have consistency in structure, I can have units numbers (ex.307) at the beginning of the text. – Fflavioo Jun 5 '15 at 15:54
  • You could explode the list and count the elements of the exploded list (ListElementCounter). Then parse each independently type of address with independent rule parsers. Eg. Lists with 5 elements one path , lists with 6 elements another path, and so on. – Jorge Vidinha Jun 5 '15 at 17:37

Assuming a comma will sufficiently split your street address into a field and the City, State, ZIP into another field, you could just use another attribute splitter with a space.

Alternatively, you could use a PythonCaller Transformer to do the work for you. Here, City/State/Zip are stored in an attribute called "Location".

The python script I used here is:

import fme
import fmeobjects
# Template Function interface:
def processFeature(feature):
    AttList = feature.getAttribute('Location').split(' ')
    City = AttList[0]
    State = AttList[1]
    Zip = AttList[2]

    feature.setAttribute("City", City)
    feature.setAttribute("State", State)
    feature.setAttribute("Zip", Zip)


The parameters of the transformer are:

enter image description here

Note, this is essentially the same as an attribute splitter. But, there are a lot of ways to skin a cat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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