inconsistent field names

633
1
10-11-2012 12:23 PM
MikeDriver
Emerging Contributor
I need to extract data from 13 point FCs where each intersects with a user-input polygon, and then output certain attribute information from each to one summary excel file.  The attribute info is basic stuff like name, address, city, state.  However, complicating things, each FC has different field names for the same item, meaning one FC may have the address field as 'address' while another will have it as 'addr' and yet another as 'address_1'.  Can anyone give advice or snippet or outline of how best to handle this?
Tags (2)
0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
Hi Mike

You could use wildcards for the field names.  Ex:

fc = "Airports"

lstFields = arcpy.ListFields(fc, "addr*")
for field in lstFields:
   rows = arcpy.SearchCursor(fc)
   for row in rows:
      print row.getValue(field.name)

del row, rows


The above code will print values for fields with names addr, address, address_1, etc.
0 Kudos