I'm wondering if anyone can help me brainstorm how to simplify this ETL process? The way I have it written, it just feels very repetitive, but I can't think of a way to avoid the repetition.
I'll eventually be feeding about a dozen feature classes, all with a different schema (different field ordering, field spellings, etc.), into one composite feature class. I've pre-determined the proper index values for each field, and as you can see, the ordering (and as I said, the spelling of field names as well) are wildly different between "fc1" and "fc2," which makes it hard to automate, thus the problem.
I'm afraid that with so many feature classes being added, the code will eventually get unnecessarily long. This example has been abbreviated by quite a lot.
I have modified the code for simplicity and confidentiality:
import arcpy, os from arcpy import env arcpy.env.workspace = r"I:\GIS_TOOLS\SDE_connections\gis_sde.sde" sde = arcpy.env.workspace masterFC = os.path.join(sde, "sde.SDE.masterFC") fc1 = os.path.join(sde, "sde.SDE.FC1") fc2 = os.path.join(sde, "sde.SDE.FC2") masterFCFieldList = ["Shape", "Id", "Name", "Address", "Zip", "Boro", "Phone"] # ---- Load feature class 1 ---- insertCursorMasterFC = arcpy.da.InsertCursor(masterFC, masterFCFieldList) searchCursorFC1 = arcpy.da.SearchCursor(fc1, *) for row in searchCursorFC1: Shape = row Id = row Name = row Address = row Zip = row Boro = row Phone = row insertCursorMasterFC.insertRow([Shape, Id, Name, Address, Zip, Boro, Phone]) del insertCursorMasterFC del searchCursorFC1 # ---- Load feature class 2 ---- insertCursorMasterFC = arcpy.da.InsertCursor(masterFC, masterFCFieldList) searchCursorFC2 = arcpy.da.SearchCursor(fc2, *) for row in searchCursorFC2: Shape = row Id = row Name = row Address = row Zip = row Boro = row Phone = row insertCursorMasterFC.insertRow([Shape, Id, Name, Address, Zip, Boro, Phone]) del insertCursorMasterFC del searchCursorFC2 print "Script Complete."