Skip to content

Instantly share code, notes, and snippets.

@M-Bryant
Last active April 4, 2022 07:48
Show Gist options
  • Save M-Bryant/7d07a16c31181d3b39b4e6b2962daaca to your computer and use it in GitHub Desktop.
Save M-Bryant/7d07a16c31181d3b39b4e6b2962daaca to your computer and use it in GitHub Desktop.
arcpy: Check if field exists
import arcpy
def fieldExists(dataset: str, field_name: str) -> bool:
"""Return boolean indicating if field exists in the specified dataset."""
return field_name in [field.name for field in arcpy.ListFields(dataset)]
@M-Bryant
Copy link
Author

M-Bryant commented Apr 4, 2022

Added type hinting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment