0

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:

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jan 25, 2017 at 0:08
1
  • That looks like a data issue. What is the full text that starts "This handsome, tall"? Commented Jan 25, 2017 at 0:30

2 Answers 2

1

It appears that TableToTable is having problems converting all of the fields in the featureclass to an equivalent field type for the DBF. Try using MakeTableView_management to create a table view with only the fields you want (those in the keepFields list) before using TableToTable.

Note that the DBF format doesn't allow a text field with over 255 characters.

answered Jan 25, 2017 at 1:05
1
  • Thanks for the advice. I ended up taking a different route, but I will test your method out in the future. Commented Jan 25, 2017 at 7:21
0

I worked around the error by converting the gdb feature class to an excel file (TableToExcel), then from excel to dbf (ExceltoTable). I then deleted the unnecessary fields. Not quite certain why this works however.

answered Jan 25, 2017 at 7:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.