I probably am going about this completely wrong.. but stuck... I HOPE this is going to make sense ... my mind is spinning...
I am trying to set a few variables at the top of the script. This script is used over and over again with minor tweaks by someone that does not understand python that well (including me)
The purpose is for someone to modify the script and add or Remove Feature Classes that will be read later in the script for COPY etc.
- As you can see below I have LayerA_DEV and Layer B_DEV in a DEV DB.
- I am defining their new location in a TEST DB with LayerA_Tst and LayerBTst
Users can add a Layer C or Layer D if they choose....
They would then have to create a NEW layersToCopy variables like the two variables layersToCopy1 and layersToCopy2 which points to the To and FROM
I then packaged those into 1 array that I read later.
I am trying to read the MAIN array which gives me 2 elements per read....
As the amount of Layers being read (LayerA_DEV, LayerB_DEV, LayerC_DEV) can increase or decrease I dont know how may variables I would need and dont want to the users to have to comb through the script to add them layer....
If they wanted to add a layer for processing they would only have to add:
LayerC_DEV = "Database Connections\\xyz.sde\\GIS_DATA.aaa_NEWFC"
LayerC_Tst = "Database Connections\\yyy.sde\\GIS_DATA.aaa_NEWFC"
layersToCopy3 = [LayerC_DEV, LayerC_Tst]
layersToCopy = [layersToCopy1,layersToCopy2, layersToCopy3 ]
All the code below would read this and there would be no need by the user to modify anything else...
How can I cycle through the layersToCopy Variable and create the required variables to populate to below
If I can get those written I could cycle through the layersToCopy Array and set the parameters for the Copy_Management
# THIS IS WHAT I AM TRYING TO DO IN THE FOR LOOP
for layers in layersToCopy:
# Read the First Value in layersToCopy [LayerA_DEV, LayerA_Tst]z
# Break apart into 2 varaibles run copy
arcpy.Copy_management(LayerA_DEV, LayerA_Tst)
# Read the Second Value in layersToCopy [LayerB_DEV, LayerB_Tst]
# Break apart into 2 varaibles run copy
# arcpy.Copy_management(LayerB_DEV, LayerB_Tst)
# Resulting in 2 new Feature Classes copied to a new DB
LayerA_DEV = "Database Connections\\xyz.sde\\GIS_DATA.aaa_LOGSHEET"
LayerB_DEV = "Database Connections\\xyz.sde\\GIS_DATA.aaa_PERMIT_I"
LayerA_Tst = "Database Connections\\yyy.sde\\GIS_DATA.aaa_LOGSHEET"
LayerB_Tst = "Database Connections\\yyy.sde\\GIS_DATA.aaa_PERMIT_I"
layersToCopy1 = [LayerA_DEV, LayerA_Tst]
layersToCopy2 = [LayerB_DEV, LayerB_Tst]
layersToCopy = [layersToCopy1,layersToCopy2]
# I want to loop thorugh layersToCopy and create 4 variables that I can use to Copy Features
for layers in layersToCopy:
for copyLayers in layers:
print(copyLayers)
RESULT:
Database Connections\xyz.sde\GIS_DATA.aaa_LOGSHEET
Database Connections\xyz.sde\GIS_DATA.aaa_LOGSHEET
Database Connections\yyy.sde\GIS_DATA.aaa_PERMIT_I
Database Connections\yyy.sde\GIS_DATA.aaa_PERMIT_I