AnsweredAssumed Answered

Python - write new row based on comma-separated values in table column?

Question asked by ascullyCOT on Feb 28, 2018
Latest reply on Feb 28, 2018 by James.MacKay

Hopefully a simple (and fun!) Python loop question.

We have a dataset that looks like this:

 

ROWIDATTRB1ATTRB2ATTRB3ATTRB4
1AAABBBCCCABCD, EFGH,IKL

 

Where ATTRB4 often contains a comma-separated list of values.  Unfortunately we need these values as a join field in a SQL view, so the comma-separated list format output we receive needs to be changed so that there is only 1 value in the ATTRB4 column

 

So, what I'm working on is creating a non-normalized version of this table (actually a feature class) that will have 3 duplicate rows (duplicate rows not a problem in this case) , with identical values for ATT1-3 but with the ATT4 value being a single one of the comma-separated list values:

 

ROWIDATTRB1ATTRB2ATTRB3ATTRB4
1AAABBBCCCABCD
2AAABBBCCCEFGH
3AAABBBCCCIJKL

 

I believe I need to get the comma-separated ATTRB4 column into a list, and loop through it, but am not quite sure how to wrap my head around the code here.  

 

Thanks

Allen

 

PS the comma-separated list values are the result of GeoEvent service (v 10.5.1) that uses a GeoFence and GeoTagger to identify points in certain areas and add the GeoFence name to the output - so when a point is within multiple areas, the multi-value list is result.  If anyone happens to know a way to force GeoEvent to output in the format shown in the 2nd table, that would work too. 

Outcomes