I have a table in which one of the fields is currently filled with a comma separated list. (Made-up sample below)
| OBJECTID | RELID | DATE | Authors |
| 1 | 3 | 7/04/1996 | T. Pratchett, N. Gaiman |
I'd like to split this so that I have a record per each author, with the rest of the information maintained.
| OBJECTID | RELID | DATE | Authors |
| 1 | 3 | 7/04/1995 | T. Pratchett |
| 1 | 3 | 7/04/1995 | N. Gaiman |
The workflow, I think, would be
- Get the table
- Search the table by row
- Split the Authors column into a list
- If there is only 1 or 0 authors, ignore it and move on
- If there are two or more authors,
- For each author, create a new row and pass the original values from the row it came from
I'm very much a beginner at this, so the following is my best guess before I ran out of ideas, specifically on how to get the original values to the new rows.
If anyone could give me some pointers, I'd really appreciate it.
import arcpy, os
from collections import defaultdict
inFC = #######
myFeatures = dict()
with arcpy.da.SearchCursor(inFC, ['OBJECTID', 'RELID', 'DATE', 'AUTHORS']) as cursor:
for row in cursor:
listA= list(row[4].split(","))
if count(listA)== 1:
""
elif count(listA) == 0:
""
else:
rows = arcp.da.InsertCursor(inFC)
for x in listA:
row = rows.NewRow()
row.setValue("RELID",
Thank you!