How does one combine rows in a table in the following fashion?

1261
6
Jump to solution
03-18-2019 02:12 PM
royceSimpson1
New Contributor

Is there a tool in ArcToolbox that can do what is illustrated in the accompanying image?  I could have sworn there was.

Thanks, Royce

x (x)
x (x)
0 Kudos
1 Solution

Accepted Solutions
MarkBryant
New Contributor III

Given you are using road centerlines and map sheets you could use a spatial join, and the merge rule for the attributes. This function allows to list the attribute values from a particular field (of the feature class that you’re joining to the target layer) and enter them into a designated field using a user-defined delimiter.

  Spatial Join - Field Map Steps

The resulting dataset should display pages that each of the roads intersect, stored as text values separated by the delimiter of your choice.

There is no control on which order the fields are merged up. So you will possibly need to run a sort on the field containing the merged attributes. You could use something like this.

def sortValues(the_value, delimiter=','):
  if the_value == None:
    return the_value
 
  # Create a Python list by splitting the string on the delimeter
  #
  the_list = the_value.split(delimiter)
 
  # Sort the list
  #
  the_list.sort()
 
  # Reassemble the string from the sorted list
  #
  rval = delimiter.join(the_list )
  return rval

 
Mark.

View solution in original post

6 Replies
MitchHolley1
MVP Regular Contributor

Dissolve should do it.. or Summary Statistics.

0 Kudos
royceSimpson1
New Contributor

I've looked at both but not seeing how to get the comma delimited valued in the second column. 

x (x)
0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor
0 Kudos
royceSimpson1
New Contributor

Not sure that will work either. 

What I'm trying to do create a road name index for a data driven pages map book.  So, I've got a map book with 300 pages and I'd like to create an index that has two fields... "road name" and "pages". Examples might be " Highway 14" "10,11,12,15,16,17"

"College Ave"  "25,29,100,200...etc.".

I took my road centerlines and dissolved based on name.  Then I did an intersect to break the roads at the page boundaries, then I did a spatial join to add the page fields onto the road centerlines.  So far so good.  But now, I have individual rows for each page that any given road shows up on.  I'd like to merge all those so that the road name only shows up in one record but the pages it's on are all together in a comma delimited string in the second column, pretty much just like that image I attached in my original post.  The crazy thing is, I did all this once before months ago and now I can't figure out what the tool was that did it.

x (x)
0 Kudos
MarkBryant
New Contributor III

Given you are using road centerlines and map sheets you could use a spatial join, and the merge rule for the attributes. This function allows to list the attribute values from a particular field (of the feature class that you’re joining to the target layer) and enter them into a designated field using a user-defined delimiter.

  Spatial Join - Field Map Steps

The resulting dataset should display pages that each of the roads intersect, stored as text values separated by the delimiter of your choice.

There is no control on which order the fields are merged up. So you will possibly need to run a sort on the field containing the merged attributes. You could use something like this.

def sortValues(the_value, delimiter=','):
  if the_value == None:
    return the_value
 
  # Create a Python list by splitting the string on the delimeter
  #
  the_list = the_value.split(delimiter)
 
  # Sort the list
  #
  the_list.sort()
 
  # Reassemble the string from the sorted list
  #
  rval = delimiter.join(the_list )
  return rval

 
Mark.
royceSimpson1
New Contributor

Bingo, that's it!  Thanks so much.

x (x)
0 Kudos