Arcpy Join Field Not Working in Pro Toolbox

1362
4
Jump to solution
11-01-2018 09:28 AM
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I have a Python script that joins a csv table to a geodatabase feature class. This works fine when I run the script in IDLE(2.7.13), but when I run this script from a toolbox in ArcGIS Pro, the field values are all null after the join. I made sure that the script is compatible with Python 3, and ran the Analyze Tools for Pro tool and found no issues. 

Here is a code snippet:

arcpy.CopyRows_management(csvReport, "roomReport")
    arcpy.JoinField_management(featureClass, "TextString", "roomReport", "RecordID", joinFields)
    arcpy.Delete_management("roomReport")
    arcpy.CalculateField_management(featureClass, "SiteFloor", "!Site! + ' ' + !Floor!", "PYTHON")
    arcpy.CalculateField_management(featureClass, "UsableSF", "int(round(float(!UsableArea!)))", "PYTHON")

One thing that is very confusing is that the join field from the featureClass is called "Text" in the attribute table. This matches to the "RecordID" in the csv table. When I run the script standalone, "TextString" works (this script was written by someone else so I'm not sure about this discrepancy). When I run the script in the Pro toolbox, I get an error "field 'TextString' does not exist in the table" which is what I would expect to happen. I've tried adding a field called "TextString" to the featureClass, and calculating it's value as "Text" but this hasn't worked. If I change the match field to "Text" in the script, it also doesn't work. 

0 Kudos
1 Solution

Accepted Solutions
deleted-user-1_r2dgYuILKY
Occasional Contributor III

OK. I added a table to table conversion from the csv with field mapping to reformat the RecordID to text and Useable Area field (text number to float) and it worked running the tool in ArcGIS Pro.

View solution in original post

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

A screen grab of the two tables would help since it isn't clear from your description what fields actually exist in both tables and whether the text case matches in both.  The two fields that you are using to join can have different names, but their contents, including text case must be identical.

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I think the issue might also be arcpy.CopyRows_management, because in standalone Python, four rows are copied from the csv to the featureClass with no issues. Run in the toolbox in Pro, all of these fields are there but the values are null. Only two of the four fields are actually calculated in the code snippet above. I looked at the formatting, and the "Text" field from the featureClass is indeed a text field. The RecordID field in the csv is general format. I tried saving it as a text field, but the issue persists. It doesn't work in Pro with the field named either "Text" or "TextString" but it works in IDLE. 

featureClass:                         CSV:

          

0 Kudos
DanPatterson_Retired
MVP Emeritus

left justified is usually text, right justified is usually numbers.  I would do the join after you make the csv a gdb table to confirm whether the csv column is being treated as text or numbers.  If it is being treated as numbers, then you will need to convert the column to a new text column

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

OK. I added a table to table conversion from the csv with field mapping to reformat the RecordID to text and Useable Area field (text number to float) and it worked running the tool in ArcGIS Pro.

0 Kudos