AnsweredAssumed Answered

Export feature class based on values from two fields

Question asked by hnavarro23 on Oct 30, 2018
Latest reply on Oct 30, 2018 by hnavarro23

Good day,

 

I want to export a feature class to a feature class but only the ones that meet a certain criteria.  I need values from field OWNER that are equal to LB and values from STATUS that are equal to ABN.  I was able to export just one of the fields expression (OWNER) using AddFieldDelimiters, but I am not sure if this allows for an expression pointing to two fields. I tried adding a second field but only OWNER was successful and all values from STATUS were exported.  Here is my script,

 

# Import system modules
import arcpy
from arcpy import env

 

# Set the workspace
arcpy.env.workspace = "Database Connections/ADMIN Edit.sde/SewerCollectionNetwork"
ArcSDE = arcpy.env.workspace
env.overwriteOutput = True

 

# Set local variables
inFeatures = "ssGravityMain"
outputLocation = "C:/Users/Navarro/Desktop/CAD"
outputDatabase = "CCTV.gdb"
outputDatabaseLocation = "C:/Users/Navarro/Desktop/CAD/CCTV.gdb"
outputFeatureClass = "GravityMain"
delimitedOwner = arcpy.AddFieldDelimiters(ArcSDE, "OWNER")
delimitedStatus = arcpy.AddFieldDelimiters(ArcSDE, "STATUS")
expressionOwner = delimitedOwner + " = 'LB'"
expressionStatus = delimitedStatus + " = 'ABN'"

 

# Creating new .gdb
print("Creating geodatabase")
arcpy.CreateFileGDB_management(outputLocation, outputDatabase)

 

# Export feature class to geodatabase
print("Exporting feature class to feature class")
arcpy.FeatureClassToFeatureClass_conversion(inFeatures, outputDatabaseLocation,
outputFeatureClass, expressionOwner)

 

Thank you in advance.

Outcomes