AnsweredAssumed Answered

Dictionary to index the last four text numbers of a featureclass field

Question asked by LarryAdgate on Oct 23, 2018
Latest reply on Oct 23, 2018 by dkwiens

#Thank you in advance for heling if you can...This script works very well except I need the dictionary to only read or #index the last 4 field text numbers. GWO[-4] creates an error. See attachment  

>>> import arcpy

...

... newfc = "C:\\Projects\\Reconcile_PostLog\\BillProject\\BillsData.gdb\\BillsList"

... basefc = "C:\\Projects\\Reconcile_PostLog\\BillProject\\BillsData.gdb\\Main"

...

... # empty dictionary

... dict = {}

...

... # read PREM_ID as key and coordinates

... with arcpy.da.SearchCursor(newfc,['GWO[-4]','DwgName']) as cur:

... for row in cur:

... dict[row[0]]= {'DwgName':row[1]}

...

... # update old feature

... with arcpy.da.UpdateCursor(basefc,['GWO[-4]','ABLOG']) as upCur:

... for row in upCur:

... # if PREM_ID is in dictionary, update x,y else skip update

... if row[0] in dict:

... row[1] = dict[row[0]]['ABLOG']

... upCur.updateRow(row)

... print "Your Indicated Field have been Updated {}".format(row[0])

...

Runtime error

Traceback (most recent call last):

File "<string>", line 11, in <module>

RuntimeError: An invalid SQL statement was used. [SELECT GWO[-4], DwgName, OBJECTID FROM BillsList]

Attachments

Outcomes