HOW TO
A field may contain multiple values for a feature. In this example, the MATERIAL field records multiple types of material (CAS, UNK, DIP) used for each feature in the same row. These values can be separated into their respective rows using ArcPy in ArcGIS Pro and this article provides the workflow.
import arcpy
in_fc = r"<Feature_Class_Folder_Location>" in_fields = ["<field_1>", "<field_2>", "<field_3>", "<field_4>"]
out_fc = r"<New_Feature_Class_Folder_Location>" out_fields = ["<field_1>", "<field_2>", "<field_3>", "<field_4>"]
data = [list(row) for row in arcpy.da.SearchCursor(in_fc, in_fields)] arcpy.management.TruncateTable(out_fc)
cursor = arcpy.da.InsertCursor(out_fc, out_fields) for row in data: if row[<number_of_splits>] is None: cursor.insertRow(row) continue for value in split_field.split(", "): value = row[<number_of_splits>] cursor.insertRow(row) print("Completed")
The code block below shows the full script.
import arcpy in_fc = r"C:\Users\Test\Desktop\Folder\Project\Test.gdb\Water_Main" in_fields = ["OBJECTID", "FACILITYID", "INSTALLDATE", "MATERIAL"] out_fc = r"C:\Users\Test\Desktop\Folder\Project\Test.gdb\Water_Main_SPLIT" out_fields = ["OBJECTID", "FACILITYID", "INSTALLDATE", "MATERIAL"] data = [list(row) for row in arcpy.da.SearchCursor(in_fc, in_fields)]
arcpy.management.TruncateTable(out_fc) cursor = arcpy.da.InsertCursor(out_fc, out_fields) for row in data:
if row[3] is None:
cursor.insertRow(row)
continue
for value in split_field.split(", "):
value = row[3]
cursor.insertRow(row) print("Completed")
The attribute table below shows each value in the MATERIAL field is split into separate rows.
Get help from ArcGIS experts
Download the Esri Support App