I'm looking for a way to get all of the values from a single field in an ArcGIS table. Reasons for doing this might include pasting the values into a text document or SQL where clause.
Since ArcGIS 10.1 does not seem to have a way to do this (like right-click the field > Copy), I would like to see if I could write an ArcPy script to do this for me. The following code will write the values to the Python window if I pass it an explicit tablename and fieldname:
import arcpy
cur = arcpy.SearchCursor("myTableName")
fieldname = "myFieldName"
for row in cur:
print row.getValue(fieldname)
del row, cur
However, to make this a dynamic tool, I would like to determine a way to identify:
- the active table (in the table window), and
- the active (highlighted) column/field in that table
at which point I can dynamically change the tablename and fieldname in the code above, based on what is selected.
Any ideas?