2

I am very new to Python and my first attempt hasn't gone too well. I'm trying to overwrite a field that is a spatial join of a couple of features in order to, in the end, generate a beginning and ending street intersections listing.

Here is a link to my table. The field I'm trying to overwrite is the IntersectionList field.

As you can see, the IntersectionList has the SECONDARYN field names included due to the spatial join. All I need now, are those streets that are not in the SECONDARYN field in order to create a beginning/ending street listing.

Here is a visual example of what I'm trying to accomplish.

This is the code I tried to use via the Calculate Field tool:

fixUpIntersections(!IntersectionList!, !FULLNAME!)


def fixUpIntersections(listAsString, streetname):
names = listAsString.split(" & ")
uniqueNames = list(set(names))
if len(uniqueNames) == 1:
    return uniqueNames[0]
    uniqueNames.remove(streetname)
return ' & '.join(sorted(uniqueNames))

I thought with the error I received, it meant that maybe I should !FULLNAME! to !SECONDARYN!, in order to get rid of those streets in the IntersectionList but when I tried that, it just deleted all data in the IntersectionList. Running the tool with the code exactly as shows above without changing !FULLNAME!, it resulted in the following error.

http://goo.gl/6xP3OP

I've dug around the site here but haven't been able to figure out my problem. I have a long way to go to learn Python.

3

The first thing that I would check is whether your feature class has a field called FULLNAME.

The error message that you are receiving suggests that it does not.

  • Yeah, that's what I thought about last night. If I'm trying to remove the names that match the names in the secondary field, I'm thinking I need to delete one of the secondaryn fields since there are two and change the !FULLNAME! to SECONDARYN. – hherrmann Apr 6 '16 at 11:55

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.