Select to view content in your preferred language

list field values - if statement

4232
2
Jump to solution
01-19-2015 07:26 AM
LaraFaelivrin
New Contributor

With help of this code I am able to summarize the Area field values of the Geology layer.

 

list = [r.Area for r in arcpy.SearchCursor(Geology)]   # Area is the attribute field that you want to list   

 

How can I bring an if statement into this code? I only want to list the Area field values if the field "Description" == "Silicate"

 

I am very thankful for any suggestions.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JérémiePedoia
New Contributor III

Hi Lara,

You can specify a whereclause in your cursor. This is the second and optional parameter of the function.

Please refer to the help page of the search cursor, and for building the SQL whereclause.

If you are using a 10.1 version or above, you might use data acces module (arcpy.da.SearchCursor) for performance improvement.

Regards.

J.

View solution in original post

2 Replies
JérémiePedoia
New Contributor III

Hi Lara,

You can specify a whereclause in your cursor. This is the second and optional parameter of the function.

Please refer to the help page of the search cursor, and for building the SQL whereclause.

If you are using a 10.1 version or above, you might use data acces module (arcpy.da.SearchCursor) for performance improvement.

Regards.

J.

LaraFaelivrin
New Contributor

Thanks that worked!:)

0 Kudos