Excel is a good tool for cobbling...But getting the data squared away is not so very difficult with scripting.Mucking about with Calculate Field is not the way to do it, however.Assuming you have already added 6 new Results (numeric) fields to your table(Result1, Result2, and so on)and that the data string is in a field called BigFunkyFieldand the fc is c:\FileGeodatabase.gdb\inFC.....This is not elegent, and not tested, but....It also turns the number strings into real numbers...
import arcpy inTable = r"c:\FileGeodatabase.gdb\inFC" cur = arcpy.UpdateCursor(inTable) for row in cur: txtStr = row.BigFunkyField sList = txtStr.split(',') newList = [] for q in sList: if q.find("voltage") >= 0: volt = q.replace('"voltage"=>', '') newList.append(long(volt.replace('"', ''))) length = len(newList) r1, r2, r3, r4, r5, r6 = 0, 0, 0, 0, 0, 0 rList = [r1, r2, r3, r4, r5, r6] for n in range(0, length): rList = newList row.setValue(Result1, rList[0]) row.setValue(Result2, rList[1]) row.setValue(Result3, rList[2]) row.setValue(Result4, rList[3]) row.setValue(Result5, rList[4]) row.setValue(Result6, rList[5]) cur.updateRow(upRow) del cur print 'Done'
for q in sList: if q.find("voltage") >= 0: newList.append(q)
txtStr = '"lit"=>"yes","maxspeed"=>"50","voltage"=>"900","voltage"=>"666","oneway"=>"yes","ref"=>"B 6","voltage"=>"110000"'
newList = []
for q in sList:
txtStr = '"lit"=>"yes","maxspeed"=>"50","voltage"=>"900","voltage"=>"666","oneway"=>"yes","ref"=>"B 6","voltage"=>"110000"' sList = txtStr.split(',') newList = [] for q in sList: if q.find("voltage") >= 0: newList.append(q) for n in newList: print n
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.