Thanks Joshua for pointing out that I wasn't very clear about the overall process at a high level!
You are correct. We have a large number of desired output datasets, each with many inputs from state, district, and field offices. People I work with have developed "crosswalk" tables, which show each desired output field on the left column, the input datasets along the top row, and which field input field should map into the output field in the cell where they intersect. A simple example might be:
Destination Field | ROW_Oregon | ROW_Arizona | ROW_Wyoming | ROW_Nevada |
---|
ROW_NAME | ROW_NM | NAME | row_nm_txt | name |
ROW_TYPE | ROW_TYPE | ROW_TP | row_tp_txt | type |
GIS_ACRES | ACRES | GIS_ACRES | AREA_ACRES | acre |
EFFECTIVE_DATE | ROW_DT | EFFECTV_DATE | ROW_DATE | date |
I am using another table which shows the desired field names, types, and lengths (for text fields) of each dataset, then adding fields to an empty feature class, using code like this:
table = "schema_table"
fields = ("field_name", "field_type", "field_length")
target = "output_fc"
with arcpy.da.SearchCursor(table, fields) as cursor:
for row in cursor:
if row[1] == "TEXT":
arcpy.AddField_management(target, row[0], row[1], "
else:
arcpy.AddField_management(target, row[0], row[1])
Once I have an empty feature class with the desired output schema, I want to create an arcpy field mapping object and use it as a parameter to the Append tool to load the data into the output feature class. Currently I am just using the stand-alone Append GP tool (with the NO_TEST option) and selecting the input fields for each output field, which is extremely time-consuming as some of our datasets have more than 90 inputs.
The examples given for creating field maps in the help documentation are pretty basic and use hard-coded field names and properties. I am wondering if it is possible to reformat the crosswalk table above in a way that I could read it with a SearchCursor and create the fieldmapping object automatically.
Hope that clears it up.
Micah