I am a complete Python novice and I have been searching and searching and so far, I am unable to find a straightforward answer to my question.
I want to write a statement that checks if a shapefile has a field "Area", and if not, make one. This is what I have:
outline="LRoutline"
if "Area" not in outline:
arcpy.AddField_management(outline, "Area", "FLOAT", 6, 3)
The If statement isn't working. When I run it again, the code gets hung up because there is already a field named "Area". Obviously, the code is not looking if there is a field named "Area" but rather it is looking for that string in the variable. How do I reference the fields inside a shapefile within an If statement? outline.Area doesn't work and neither does !Area!. I have tried the SearchCursor thing using the following code and it outputs <Cursor object at 0x137ed0f0[0x13587f80]>, and I don't know what that means.
arcpy.SearchCursor(outline)
Furthermore, I want to sum the areas in that Area field after they are calculated, so I need to be able to reference the field, right? I looked at the arcpy.Statistics_analysis() function and I need to create a whole separate table to pull one value from the shapefile? That's not required to view the summary statistics in the ArcGIS GUI (right click on field in attribute table-> Summary...). Is there a less cluttered way to sum the entries in a shapefile field in Python?
I have downloaded the shapefile package but that doesn't seem to fit what I need either.