aaridd18

Insert single record into table; append attribute table

Discussion created by aaridd18 on Apr 4, 2012
Latest reply on Apr 9, 2012 by curtvprice
Hi all,

Sorry if this is an obvious question, but I don't understand cursors very well at all (though I presume they're what I need to use here). This question is also part of a larger script I'm writing. This script iterates through hundreds of point files to run Mean Center on each file, then Near to determine the distance from the center point to another shapefile. Like so:

#"for" loop calls only point feature classes in the workspace
#MeanCenter_stats creates a new point shapefile with a single point, the mean center of the points extracted in the previous step
#rename the resulting shapefiles 
for fc in arcpy.ListFeatureClasses ("*", "Point"): 
    outmean= fc[:6] + "m"
    arcpy.MeanCenter_stats (fc, outmean)

#"for" loop calls only point feature classes with the phrase "mean" in their filename
#Near_analysis adds new columns to the mean center point file 
#"infeat" is a single shapefile containing the borders of public lands in California
#note: I can change this to Generate Near Table if it's easier, but I doubt it will be
for fc in arcpy.ListFeatureClasses ("m", "Point")
    infeat= "S:\FIRE\ben_data\NPSFSBLM"
    arcpy.Near_analysis (fc, infeat)

for fc in arcpy.ListFeatureClasses ("m", "Point")
    outtable = r"S:\FIRE\73to80.dbf"
    arcpy.AppendManagement (fc, outtable, "NO_TEST", "", "")


When this is done I need to iteratively append the results to an existing table. However, before I do this I need to import the UID from each file into the same row in the table. The UID is not contained in the attribute table of any of the files--it's in the filename. I presume I need to insert a cursor into the relevant row and field and use some kind of slice operation to extract the UID, but I'm really not sure how to do this. Also, I don't think the syntax I'm using for Append is correct, but don't know what the syntax is for the attribute table rather than the feature class.

Outcomes