Select to view content in your preferred language

GP tool to split field with comma-delimited values into multiple rows

434
5
03-15-2024 11:54 AM
Status: Open
Labels (1)
Bud
by
Esteemed Contributor

As @Ed_ mentioned in Split comma separated values to multiple rows:

...I am trying to split each comma separated value in `MUNICIPALI` column [into rows] as shown in desired output.

Sample Data:

OBJECTIDPRJTIDMUNICIPALIZIPCODE
11A1
22A, B1,2
33A, B, C1,2,3
44A, B, C, D1,2,3,4
55A1
66C3

 

Desired output:

OBJECTIDPRJTIDMUNICIPALIZIPCODE
11A1
22A1
32B2
43A1
53B2
63C3
74A1
84B2
94C3
104D4
115A1
126C3

 

Could an OOTB geoprocessing tool be added that could split comma-separated values into rows?

5 Comments
JoshuaBixby

Now that Summary Statistics (Analysis)—ArcGIS Pro | Documentation supports concatenation, we need a tool to do the inverse. 

MultiAttribute-To-SingleAttribute.png

 

Either

  1. Multipart To Singlepart (Data Management)—ArcGIS Pro | Documentation could be enhanced to support attributes beyond multi-part geometries.
  2. A new 'Multi-attribute to Single-attribute (Data Management)' tool could be created.

The splitting tools in the Extract toolset do not address this need for several reasons.

 

Bud
by
JoshuaBixby

Bud, I thought I saw a similar idea in the past but couldn't find it while searching, hence me posting it.  For now, I will leave my idea up too and Esri can decide to merge them or not.

DrewFlater

@JoshuaBixby your idea has been merged here. Your diagram is really nice! 

Can you explain what process requires the multiple rows or why you want to "explode" the concatenated values to multiple rows? Your diagram and the previous explanation are very clear about what the request is, and the arcgis-pro-question at the top has a code sample to accomplish this. 

A subtle difference in the original request seems to be exploding multiple fields. I don't know if the matching of the items between two or more fields is expected to me at least -- PRJTID=2 turns into two records based on positional matching, rather than exploding to rows with all possible combinations. 

JoshuaBixby

@DrewFlater, I don't know if what Bud and I have in mind are exactly the same, but they are similar enough to merge for discussion on the requests.

Looking at the original example, it appears the OP is asking for a pairwise combination, one might call it "zipping".  I am more interested in a cross product that results in a straight combination if multiple fields are selected.  For example,

OBJECTIDPRJTIDMUNICIPALIZIPCODE
22A1
32A2
42B1
52B2

 

The main use case I have run across is a form of re-normalizing tables from data warehouses.  Re-normalizing redundant attribution can be as straightforward as removing columns, but when information has been concatenated for reporting purposes the attribution needs to be exploded.

I realize there is readily available code for doing this task, and I am a big advocate for scripting over GUI-driven clickops, but I also work in and support an organization with tens of thousands of GIS users and a vast majority of those users solely rely on the GUI and geoprocessing tools.