jpedder

SearchCursor error - Field was not found or could not be retrieved

Discussion created by jpedder on Jul 30, 2012
Latest reply on Jul 30, 2012 by jpedder
Hi folks, I have what is probably just a syntax error that i could really use some help with.

I have 2 FC's with a common field Period which is of type short int

I display the value of my var OpPeriod and it's returned correctly. 1, 2 etc.

In my search arcpy.SearchCursor if I manually type the number in the script works, however when I try to use my var it bombs with the above error.

Code sample that works

OpPeriod = row.getValue("Assignments.Period")

    fc4 = "Operation_Period"
    arcpy.AddMessage(fc4)
    rowPeriod = arcpy.SearchCursor(fc4, '"Period" = 1')
    arcpy.AddMessage(rowPeriod)
    for x in rowPeriod:
        arcpy.AddMessage(x)
        vWeather = x.getValue("Weather")
        arcpy.AddMessage(vWeather)
    del x


code sample that goes bang!

OpPeriod = row.getValue("Assignments.Period")

    fc4 = "Operation_Period"
    arcpy.AddMessage(fc4)
    rowPeriod = arcpy.SearchCursor(fc4, '"Period" = OpPeriod')
    arcpy.AddMessage(rowPeriod)
    for x in rowPeriod:
        arcpy.AddMessage(x)
        vWeather = x.getValue("Weather")
        arcpy.AddMessage(vWeather)
    del x


Thanks in advance for your help

Jon

Outcomes