Skip to content

Instantly share code, notes, and snippets.

@pmgreen
Created September 15, 2025 00:53
Show Gist options
  • Save pmgreen/3662b05c16757ecda977724887207da9 to your computer and use it in GitHub Desktop.
Save pmgreen/3662b05c16757ecda977724887207da9 to your computer and use it in GitHub Desktop.
Get field names from QGIS attribute table
# generated from multiple sources by Brave Leo (AI)
# from the Python console in QGIS:
# activate the layer you want field names for and then enter...
from qgis.utils import iface
layer = iface.activeLayer()
prov = layer.dataProvider()
field_names = [field.name() for field in prov.fields()]
for f in enumerate(field_names):
print(f"{f}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment