I have a table in my geodatabase that has urgent care patient visits listed by market. I'm trying to develop a script that will select a certain lyrx based on what market the patient visit took place in. From the research I've done, it looks like the "if", "elif", and "else" statements would accomplish what I'm trying to do.
I'm thinking it would something like this:
if
Market_ID
=
=
"1000"
:
print
"NY_ZipCodes"
elif
Market_ID
=
=
"2000"
:
print
"CT_ZipCodes"
elif
Market_ID
=
=
"3000"
:
print
"CA_ZipCodes"
else
:
print
"This program has an error"
Obviously I need to replace the "print" statement (with the exception of "else"), but I don't know what to replace it with.
Does anyone know what should replace "print"? Am I on the right track? Is there a better way to do what I'm trying to do?
What do you mean you're trying to select a .lyrx? Like, pick out a file from a directory? Or query an ArcGIS layer?
I want it to select a .lyrx from a geodatabase from within an ArcGIS Pro project. Does that answer your question?
If the layers are in the geodatabase, then the code sample(s) allow you to retrieve the list. It is a matter then of comparing through your 'if' statement.
my_layers = # this is where you get the list
if Market_ID == "1000": # ---- don't put " " around numbers unless they are text ----
if "NY_ZipCodes" in my_layers:
# then do something
elif ........
# etc
You had better get a list of layers and if the lyrx files reside on disk, then you will have to provide the paths to them. I think your 'if' statement comes later, I would examine the code examples in the help topic I highlighted.