I am trying to strip "$" from attributes in the Name field or all the fields in a feature class table prior to exporting out the table.
Could you strip the "$" from attributes in the Name field or all the fields in arcpy.MakeQueryTable_management prior to exporting if so how? I am not sure which would be the fastest?
I have the following but i am getting an error on line 8.
Error:
line 8, in <module>
r.OwnerName = s.strip("$")
AttributeError: 'NoneType' object has no attribute 'strip'
import arcpy fc = "C:/Temp/Default.gdb/yogurt" rows = arcpy.UpdateCursor(fc) for r in rows: s = r.Name r.Name = s.strip("$") rows.updateRow(r)
Thanks.
r.Name = s.replace("$","")
but a None Type means you have blanks returning None
PS where did r.Ownername come from???
the r.OwnerName is a typo, it should have just been r.name = s.strip("$"), my bad.
How do make an exception for the None Type with my current code?
Can the $ be striped from a arcpy.MakeQueryTable_management?
Thanks.
Of course it can... assuming one could see the whole code section
How do make an exception for the None Type with my current code?
This will skip the null fields and hopefully solve your problem.
Note, using arcpy.da.UpdateCursor may be 10-100x faster, making your question about the query table maybe not that important...
with arcpy.da.UpdateCursor(fc, "Name") as rows: for r in rows: if r != None: r[0] = r[0].replace("$", "") rows.updateRow(r)