AnsweredAssumed Answered

User Input Conditional ( x in vs x ==)

Question asked by EscondidoAnalyst on Sep 25, 2017
Latest reply on Oct 2, 2017 by EscondidoAnalyst

I am having an issue with raw_input as a variable x. The user types the name and receives returned values. x is in the ly variable is not working.( Line 20) I know that I need to set this up slightly different but not sure how. (Line 22,23)

 

I can set the variable x as a hardcoded name and I get the correct results which confirms everything else is correct. (Line 21)

 

import arcpy
import os
#Set folder space
folder = r'S:\\GIS\ServerMXDs\\_Future_Services\\CityWorks'

for filename in os.listdir(folder):
    fullpath = os.path.join(folder, filename)
    if os.path.isfile(fullpath):
        basename, extension = os.path.splitext(fullpath)
        if extension.lower() == ".mxd":
            mxd = arcpy.mapping.MapDocument(fullpath)
            dfs = arcpy.mapping.ListDataFrames(mxd)
            for df in dfs:
                layers = arcpy.mapping.ListLayers(mxd, "", df)
                for layer in layers:
                    if layer.isFeatureLayer:
                        lyr_source = layer.dataSource
                        lyr_name = layer.name.encode("utf8", "replace")
                        ly = lyr_source.encode("utf8", "replace")-
                        #x = raw_input("type in feature name: ")
                        x = 'ServiceEstablishments'
                        if x in str((ly.split ('\\')[2:])):
                            print filename + " " + "Service Name:" + " " + df.name + " " + "Layer Name:" + " " + lyr_name


                

 

 

 

 


                 
                        

Outcomes