I'm a GIS MA student looking for some help on creating a Python script in ArcGIS for a class project. I have a text table with several fields (Tenant Name; Address; Sq Ft; Destination). The destination column contains information that I want to separate into two new fields - one for the first word in the original column and one for the second word in the original column. I then need to write this new info back into the original table.
What ArcPy commands should I be looking at to accomplish this? Can anyone point me to a similar finished script?
Ahh, I mistook last value for last whole word. Is there a modifier to the row.Type = row.Dest statement that can select the entire last word from the original row?
#following exectues the add field if len(theFieldList) == 0: arcpy.AddField_management(inputTable, "Type", "TEXT") else: arcpy.AddMessage ("Field Exists") #split field loop rows = arcpy.UpdateCursor (inputTable) #gets all vlaues for table
for row in rows: #loops through vlaues and updates new field basedon last word of orig field row.Type = row.Dest.split(" ")[-1] if " " in row.Dest else "" rows.updateRow(row)
del row del rows
resulting table has a new field "Type" with the second word from the "dest" row copied over. If no second word nothing is copied over. Thanks for the help all!
hi iam trying to do the same thing.. ive got a text field that contains an address each seperated with a "," i want to split into three new fields between the comers. for example
28, king road, new york
i want to be able to have the following field's 28 king road new york