Select to view content in your preferred language

Python Script for Dissolving Geodatabase Feature Classes

646
2
07-30-2022 12:55 PM
BartManders
New Contributor

Hello,

I have been trying to create a script for dissolving several geodatabase feature classes on ArcGIS pro. However, the script does not seem to be working. Could someone tell me what the problem is. I have tried two versions (I am new to python and arcgis pro) :

arcpy.env.workspace = "D:\WB_Data\WB_gp.gdb"

fcList = arcpy.ListFeatureClasses()

output_name = "C:\\Users\\Bart Manders\\Documents\\ArcGIS\\Projects\\MyProject_Dissolve\\MyProject_Dissolve.gdb\\%s_Dissolve"

fields= ['gp']

for fc in fcList:    arcpy.Dissolve_management(fc, output_name % fc, "gp FIRST", "MULTI_PART", "DISSOLVE_LINES", '')

 

 I get an error 00622: Failed to execute (Dissolve). Parameters are not valid. **Error 000800:**The value is not a member of MULTI_PART| SINGLE_PART.

another version is:

 

arcpy.env.workspace = "D:\WB_Data\WB_gp.gdb"

fcList = arcpy.ListFeatureClasses()

fields= ["gp"]

for fc in fcList:
arcpy.management.Dissolve(fc, output_name + "\" + fc + "_Dissolve", "gp FIRST", "MULTI_PART", "DISSOLVE_LINES", "")

For this version I get the error 

SyntaxError Traceback (most recent call last)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ast.py, in parse:

Line 50: return compile(source, filename, mode, flags,

SyntaxError: invalid syntax (<string>, line 2)

 

 

0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

Code formatting ... the Community Version - Esri Community

Is this the full code?  Is it being used in a model? ( the % thing in the script)


... sort of retired...
0 Kudos
mody_buchbinder
Occasional Contributor III

Without too many checks I would say that:

output_name + "\" + fc + "_Dissolve"

Should be output_name + "\\" + fc + "_Dissolve"

Have fun

0 Kudos