Select to view content in your preferred language

Join Feature service with Csv using Add Join tool using Python

422
1
09-14-2023 04:24 AM
Labels (3)
BhupendarBhandari
Emerging Contributor

Hi,I am trying to Join A feature service with an excel sheet's data using Add Join tool and both of them have a field in common below is the snippet:

now = int(dt.datetime.now().timestamp())
file_name='data_table'+str(now)

file_path=os.path.join(os.getcwd(),"MyProject1.gdb",file_name)

arcpy.conversion.ExcelToTable(xlsx_file_path, file_path)

arcpy.MakeFeatureLayer_management("https://services7.arcgis.com/yxpZft6sXAxt864n/arcgis/rest/services/countries/FeatureServer/0", out_layer='fclyr')
arcpy.MakeTableView_management(file_path, 'table_view')
arcpy.management.AddJoin('fclyr', 'ISO_A3',file_path, 'iso_code')


Here, I am able to create the join but not able to map one to many relationship between the tables, also the join created as a result has random field namesimage.pngimage.pngimage.png
can anyone help?


0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

There are lots of warnings about "unexpected results" in the help topic (eg both files being indexed)

Add Join (Data Management)—ArcGIS Pro | Documentation

You might be advised to create a gdb table first prior to doing the join rather than relying on non-local data in a non-native format.

Have a read through the help topic to see if you can modify your workflow to overcome some of your observations


... sort of retired...
0 Kudos