I want to join the attribute table of a shapefile with an externally created csv table via ArcPy.
The format of the columns are:
for attribute table: "Variable1" "Variable2" "Variable3" "CATCHID" "Variable 4"...
for csv table: "CATCHID" "Results1" "Results2"...
I want to append the attribute table with the contents of the csv table with respect to the "CATCHID" column. Since my csv table doesn't have OID's, I couldn't use JoinField_management function. Hopefully, there's another function named AddJoin_management, it is really useful when used in ModelBuilder, but it is a mess in ArcPy since it requires a table view/feature layer as an input. I made a feature layer, joined two tables and copied the feature layer to a brand new shapefile but this time the names of the columns were changed as "[attributetablename].Variable1", "[attributetablename].Variable2" etc. and they are truncated while creating the new shapefile.
Is there a way to join two tables PROPERLY using ArcPy? (which means I don't want to see the layer names predicate the variable names in the columns.)
inputShapefile = r"C:\\input.shp" inputPath = r"C:\\input.csv" outputPath = r"C:\\output.shp" arcpy.MakeFeatureLayer_management(inputShapefile, "tempLayer") arcpy.AddJoin_management("tempLayer", "CATCHID", inputPath, "CATCHID", "KEEP_COMMON") arcpy.CopyFeatures_management("tempLayer", outputPath)
Here's the code snippet that I have problem with. This join operation produces a new shapefile that includes "[input].CATCHID" as a column header, for instance. However I need just "CATCHID" as the header.