Newbie for loop question

Discussion created by am00012 on Nov 17, 2011
Latest reply on Dec 2, 2011 by am00012
Hi there,

I am trying to move an ID number from the attribute table of a census block file to the attribute table of a roads file. The blocks are all separate feature classes in a gdb and the roads file is one single layer. So far I've decided that the simplest way to do this may be to select all roads with their center in each block, get the STFID from the block attribute table, then assign that STFID to the roads selected in the roads attribute table. The code I've got so far will select all roads at the same time, instead of running through the process one at a time. Current syntax as follows:

>>> import arcpy
>>> #Set geoprocessing environment
>>> arcpy.env.workspace = ("H:\Dr. Hines\New File Geodatabase.gdb")
>>> arcpy.env.overwriteOutput = True
>>> #Create list of all blocks
>>> fcList = arcpy.ListFeatureClasses("*blk00")
>>> #Create loop
>>> for fc in fcList:
...      blk = fcList
...      arcpy.SelectLayerByLocation_management("Analysis Roads","HAVE_THEIR_CENTER_IN")
...      for fc in fcList:
...         rows = arcpy.InsertCursor(blk)
...         row = rows.newRow()
...         row.STFID = ()
...         fieldVal = row.getValue("STFID")
...         arcpy.CalculateField_management("Analysis Roads","STFID","fieldVal")
Runtime error <type 'exceptions.RuntimeError'>: ERROR 999999: Error executing function.

any help is greatly appreciated!