Another simple question - close feature class or shapefile without closing script

Discussion created by tlsilveus on Apr 5, 2011
Latest reply on Apr 5, 2011 by tlsilveus
I have the following script (partial shown)
... So really I have two questions -
1) how do I close the shapefile without having to exit all the way out of pythonWin?
2) why is my code not working...too general huh... I check to see if a field exists and if it doesn't, I add it - that part works fine... next I try to set up a search cursor based on a where clause so that I can update another cursor - my search cursor never gets loaded so there is nothing for the update cursor to work off of.... Basically, I don't have arcInfo level license so I'm trying to recreate the joinField function from arcInfo at the arcView license level.  I'm an experienced programmer, but not familiar with either python or arcpy.

    #check to see if it has the field that will be updated, if it has it good; if not then add the field
    if not updateFieldParam in updateTheFields:
        #field does not exist - need to add field
       arcpy.AddField_management(updateDSParam,updateFieldParam,fieldTypeDictionary[fldType], fldPrecision, fldScale, fldLength) #adds field to data set

    updateTheRows = arcpy.UpdateCursor(updateDSParam) #get the rows from the shapefile that will have a field updated
    for updateTheRow in updateTheRows:
        #loop through all the rows in the update cursor
        if linkTypeText:
            whereClause = "!" + searchLinkParam + "! = '" + updateTheRow.getValue(updateLinkParam) + "'"
            whereClause = "!" + searchLinkParam + "! = " + updateTheRow.getValue(updateLinkParam)
        searchTheRows = arcpy.SearchCursor(searchDSParam,whereClause)
        for searchTheRow in searchTheRows:
            if searchTheRow.getValue(searchFieldParam) <> "":
                break #exit search cursor loop - you found first row with data and updated row
        searchTheRows = None
    updateTheRows = None

My indents are correct... they just didn't translate correctly on the forum
the "search cursor" comes from a table in a geodatabase not a shapefile
the "update cursor" is a feature class in a geodatabase