I'm interested in generating a dbf from a feature class in a gdb. I am also interested in selecting only 6 out of the many fields, which is why I added steps to keep only wanted fields. I am using python on ArcMap and ArcCatalog 10.3.1. Here is the code:
fc = r"C:\Users\migrate\Desktop\SFBG_GIN_Test\gdb\SFBG_GIN_Test.gdb\PlantCenter_Test" dbfLocation = r"C:\Users\migrate\Desktop\SFBG_GIN_Test\dbf" dbfOutputName = "Plants_GIS" dbfPath = dbfLocation + '\\' + dbfOutputName + '.dbf' if arcpy.Exists(dbfPath): # This line exists to overwrite any existing dbfs dm.Delete(dbfPath) arcpy.TableToTable_conversion (fc, dbfLocation, dbfOutputName) # Get all fields in dbf and remove unwanted fields fields = arcpy.ListFields("fc_temp") keepFields = ['GIS_2016_08_25', 'SourceAcce', 'AccessionC', 'SectionNam', 'Longitude', 'Latitude'] dropFields = [x.name for x in fields if x.name not in keepFields] dm.DeleteField (dbfPath, dropFields) print "DBF created"
I get the following error: