Ok, I have the following python script which migrates and maps fields and the values of those fields into a target Feature Class.
I have several feature classes to run this script on. AN exmaple of the Feature Classes that I need to run my script on are :
WDFW_CCT_2HEM_evt_olay
WDFW_CHFA_2HEM_evt_olay
WDFW_CHMF_2HEM_evt_olay
WDFW_CHSP_2HEM_evt_olay
WDFW_CHSU_2HEM_evt_olay
WDFW_COHO_2HEM_evt_olay
WDFW_DBT_2HEM_evt_olay
WDFW_KOK_2HEM_evt_olay
WDFW_RBT_2HEM_evt_olay
WDFW_SOCK_2HEM_evt_olay
These feature classes are represented in several geodatabases (see image)
Attachment 20670
I could simply go to each individual geodatabase and run the script for each featureclass in that geodatabase. This however seems redundant and I would like to figure out how to batch my scrip or automate this process. All geodatabases are located in one working directory.
I appreciate any help or advice!
Code:
# Import arcpy module
import arcpy
arcpy.env.workspace = "G:\ChrisGIS\WDFW_NWIFC_EVENT_17100101.gdb"
arcpy.env.overwriteOutput = "True"
def GetFieldMappings(inputFC, targetFC, dico):
field_mappings = arcpy.FieldMappings()
field_mappings.addTable(inputFC)
for input, output in dico.iteritems():
field_map = arcpy.FieldMap()
field_map.addInputField(inputFC, input)
field = field_map.outputField
field.name = output
field_map.outputField = field
field_mappings.addFieldMap(field_map)
del field, field_map
return field_mappings
#Variables
inputFC = "WDFW_CHFA_2HEM_evt_1"
targetFC = "WDFW_CHFA_2HEM_evt_olay_1"
dico = {'Permanent_Identifier': 'Permanent_ID',
'STRM_NAME': 'LLID_STRM_NAME',
'DATE_SRVY': 'SOURCE_DATE',
'SPPCODE': 'SPECRCODE',
'SRC_AGENCY': 'SOURCE_AGENCY',
'SRC_WHO': 'SOURCE_WHO'}
Mapper = GetFieldMappings(inputFC, targetFC, dico)
# Process: Append
arcpy.Append_management(arcpy.env.workspace+"\\"+inputFC, arcpy.env.workspace+"\\"+targetFC,"NO_TEST",Mapper)
WDFW_CCT_2HEM_evt_olay
WDFW_CHFA_2HEM_evt_olay
WDFW_CHMF_2HEM_evt_olay
WDFW_CHSP_2HEM_evt_olay
WDFW_CHSU_2HEM_evt_olay
WDFW_COHO_2HEM_evt_olay
WDFW_DBT_2HEM_evt_olay
WDFW_KOK_2HEM_evt_olay
WDFW_RBT_2HEM_evt_olay
WDFW_SOCK_2HEM_evt_olay
These feature classes are represented in several geodatabases (see image)
Attachment 20670
I could simply go to each individual geodatabase and run the script for each featureclass in that geodatabase. This however seems redundant and I would like to figure out how to batch my scrip or automate this process. All geodatabases are located in one working directory.
I appreciate any help or advice!