import arcgisscripting import logging logger = logging.getLogger() gp = arcgisscripting.create(9.3) gp.OverWriteOutput = True gp.Workspace = "C:\ZP4" fcs = gp.ListWorkspaces("*","Folder") for fc in fcs: print fc rows = gp.UpdateCursor(fc + "//Parcels.shp") row = rows.Next() while row: Name = row.GetValue('APN').replace('"', '') print Name row.SetValue('Apn', Name) rows.updateRow(row) row = rows.Next() del row del rows
row = rows.Next() while row: <do stuff> row = rows.Next() del row, rows
gp.CalculateField_management(fc + "\\Parcels.shp", '"%s" % (!SIT_FULL_S!.replace('"','')'), "PYTHON", "")
rows = gp.UpdateCursor("//Parcels.shp") for row in rows: row.name = row.GetValue("Name").replace("-", "") rows.updateRow(row) del row del rows
import arcgisscripting import logging logger = logging.getLogger() gp = arcgisscripting.create(9.3) gp.OverWriteOutput = True gp.Workspace = "C:\ZP4" fcs = gp.ListWorkspaces("*","Folder") for fc in fcs: print fc rows = gp.UpdateCursor("//Parcels.shp") row = rows.Next() while row: name = row.GetValue("Name") dash = string.find(name, "-") if dash != -1: fix = name.replace("-", "") del row, rows
gp.CalculateField_management(fc + "\\Parcels.shp", "!SIT_FULL_S!.replace('\"','')", "PYTHON", "")
expression = "!SIT_FULL_S!.replace('\"','')" print expression gp.CalculateField_management(fc + "\\Parcels.shp", expression, "PYTHON", "")
" ".join(!FIELDA!.split())
gp.CalculateField_management(fc + "\\Parcels.shp", "!SIT_FULL_S!.replace('"','')", "PYTHON", "")Looks like you forgot the closing quote on the formula string. Not sure why the cursor didnt work though.
I think I just did it in the python window. import arcpy cursor=arcpy.UpdateCursor(your feature class) for feature in cursor: if '"' in feature.YourField: #if a double quote is in the string returned, feature.YourField=feature.YourField.replace('"','') #replace that double quote with an empty string (removes it) cursor.UpdateRow(feature) That should work. Let me know if it doesnt.
import arcpy cursor=arcpy.UpdateCursor(your feature class) for feature in cursor: if '"' in feature.YourField: #if a double quote is in the string returned, feature.YourField=feature.YourField.replace('"','') #replace that double quote with an empty string (removes it) cursor.UpdateRow(feature)
Well with python you can use a cursor to go over the features and when it finds a " it can take it out. I had to do that recently on one of my feature classes as well.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.