AnsweredAssumed Answered

Split attribute into multiple rows using python

Question asked by on Mar 29, 2018
Latest reply on Mar 30, 2018 by rborchert

I have a road network polyline shapefile with a text attribute called CODE that looks like this:


(3: 79, 279, 4729)


This means that this particular polyline is a part of road 79, 279 and 4729. So the number before the colon says how many roads share this segment, and after that there are road codes separated by a comma. I need these roads dissolved into separate overlapping lines, one for each road code.


So far I have copied the roads so that I have N copies of every polyline with code (N:...). I have also copied their previous FID into another column (FID_copy), so I have an attribute that identifies every set of overlapping road segments. And now I have to split the code attribute so that every copy I've made has only one road code (order doesn't matter).


So from one polyline with attribute (N: x, y, z) I need N polylines each with one single attribute x, y and z.


My idea is to loop over FID_copy to get a selection of duplicated rows in table. Then do a second (nested) loop for every selected row. I would store the code attribute in a list, and use the UpdateCursor to write the values from the code_list into the attribute field. I would also need another attribute that increases by 1 every nested loop, so it works as an index for the code_list.


Would something like this work?I am just starting to learn programming, I have very little experience yet (just esri VC courses and codeacademy) and this problem kind of leaves me clueless. My biggest issue right now is the first loop.