Basic Join Question

512
2
06-18-2011 09:24 AM
DavidHattis
New Contributor
Hi Everyone,

I am trying to do a basic join between a table and a shapefile in a Python script.  When I perform the join with a python script, the resulting shapefile loses all of the field names.  The resulting shapefile has fields like this: "census20_1", "census_20_2", etc. instead of the original field names.  However, when I do the exact same process within ArcGIS (with the same "Add Join" tool) using point and click, the field names are preserved.  Below is my code:

import arcpy, arcview

Census_Shapefile=r'C:\Desktop\Program_Notes\Python\census2000blockgroups_poly.shp'
table=r'C:\Desktop\Program_Notes\Python\education_attainment_by_gender_age.dbf'
Census_Shapefile_Joined=r'C:\Desktop\Program_Notes\Python\Census_Shapefile_Joined.shp'

arcpy.MakeFeatureLayer_management(Census_Shapefile, "Census_Shapefile")

arcpy.AddJoin_management("Census_Shapefile", "LOGRECNO", table, "LOGRECNO")

arcpy.CopyFeatures_management("Census_Shapefile", Census_Shapefile_Joined)


Is it possible to perform a join using Python that preserves the field names without using an ArcInfo tool?

Thanks
Tags (2)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
check the "qualified fieldnames" environment setting and its code example to see if this applies to your situation
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001w00000008000000.htm
0 Kudos
DavidHattis
New Contributor
Yeah, I just had to set the qualified field names to false, and it worked.  Thanks a lot!
0 Kudos