Created
August 6, 2018 21:19
-
-
Save pyRobShrk/c791d22ba2823d013140997a3370e4dc to your computer and use it in GitHub Desktop.
ArcPy function to copy the attribute table to clipboard for pasting into Excel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def GIStable2Clipboard(inTable, exportFields="all"): | |
desc = arcpy.Describe(inTable) | |
if exportFields =="all": | |
exportFields = [f.name for f in arcpy.ListFields(inTable) if not f.name == desc.shapeFieldName] | |
aliases = [f.aliasName for f in arcpy.ListFields(inTable) if not f.name == desc.shapeFieldName] | |
pd.DataFrame.from_records(arcpy.da.TableToNumPyArray(inTable,exportFields), | |
index=desc.OIDFieldName, columns=aliases).to_clipboard() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment