ArcGIS Pro 2.6: A geoprocessing tool to concatenate values of a table,

7547
32
08-09-2020 01:14 AM
Status: Implemented
Labels (1)
JamalNUMAN
Legendary Contributor

ArcGIS Pro 2.6: A geoprocessing tool to concatenate values of a table,

 

It would be great if we got an out of the box geoprocessing tool that concatenates values of a table. I’m aware of that such tool could be available but I wanted this tool to be built in in the Pro

 

In the screenshot below, the result of concatenation of attribute table P1 is represented in the stand-alone table T3

32 Comments
MajdoleenO_A__Awadallah

Yes, I got the same results as you!! but this is not our case, I want it to concatenate all the values the got the same type in one row, in your case, it writes the locality, type!! please have a look on the attached photos provided by Jamal!!

DanPatterson

That is a "summarize" operation

MajdoleenO_A__Awadallah

Summarize only count the number and does not concatenate all the values in one row! 

ColeAndrews

In my opinion, the misunderstanding across this thread is due to the title. "Concatenate values of a table" sounds like what Dan Patterson is trying to answer, but that's not exactly the request. You have to actually look at the pictures to understand the request.

I would suggest either revising the title. I'm not sure if you can do that, or if Kory Kramer has to. As Joshua Bixby stated, I would consider this an enhancement to the summary statistics tool or the pivot table tool. "expanding Summary Statistics functionality to support concatenation of string/text field"

JamalNUMAN

Thank you for the input Cole.

 

Correct. Sometimes words fail to explain the idea. This is why I support my words with screenshots to precisely describe the idea.

DuncanHornby

As Cole and Dan indicate this can be done as a fairly simple python script which you could wire up as a tool and then you would have your tool!  I put together the code for you, it is below:

The code is designed to be run from the python script window in ArcPro but with not much effort could be turned into a tool that you could drag 'n' drop into modelbuilder.

Hope it helps

# -*- coding: utf-8 -*-
"""
Title:  Group and Concatenate into table

Usage:  Edit inputs and run this code in Python window in ArcPro.

Author: Duncan Hornby

Created: 21/8/20
"""
import arcpy
from collections import defaultdict as dd
d = dd(list)
arcpy.env.overwriteOutput= True

# Inputs
fLayer = "fcTest"          # The layer in your TOC
outPath = r"c:\scratch"    # The output table path
outName = r"testOut.dbf"   # The output table name
fullPath = outPath + "\\" + outName
fields = ["local","type"]  # field to concatenate is local grouping by type
outFields = ["Type","Locality"] # Fields in output table

# Create the group and concatenation
with arcpy.da.SearchCursor(fLayer,fields) as cursor:
    for row in cursor:
        loc = row[0]
        typ = row[1]
        d[typ].append(loc)

# Create output table
arcpy.CreateTable_management(outPath,outName)
for fn in outFields:
    arcpy.AddField_management(fullPath,fn,"TEXT",None,None,50)
    
# Write results to table    
with arcpy.da.InsertCursor(fullPath,outFields) as inCursor:
    for k,v in d.items():
        commastring = ','.join(v)
        row = (k,commastring)
        inCursor.insertRow(row)
        
# Finished!
print("Finished!")
JamalNUMAN

Many thanks Duncan,

 

My point here is trying to suggest adding as many basic tools as possible to be out of the box so that they got available with the software installation.

KoryKramer

We've entered [ENH-000133689: Expand Summary Statistics functionality to support concatenation of multiple string/text fields.] into our support system.  I associated this idea with that request, but if anybody is interested in being attached directly to the enhancement request, you can contact technical support.

The current thinking is that this will not be summing text, rather joining the string fields using a delimiter specified by the user.

JoshuaBixby

Thanks Kory.

JamalNUMAN

Thanks Kory.

 

Then are we going to obtain T3 out of P1 as shown in the screenshot below?