I'm doing an interface using ArcGIS and Python scripts that run at Python window. For each time that my sript run, I need to update information, so I think that I need to delete originals tables and create news.

When I try to do this with ExcelToTable it gives me an error to add field:

arcpy.env.workspace = "F:\Otim\inter"
arcpy.Delete_management(c_re) #delete layer
c_re=arcpy.ExcelToTable_conversion("02_Rea.xlsx", "cg1_re_otim.dbf", "Rea_L")
#arcpy.env.workspace = "F:ArcGIS\Trab\Model\Result"
arcpy.AddField_management(c_re, "Name_Ba", "Text", 50, "", "", "refcode", "NULLABLE", "REQUIRED")
arcpy.AddField_management(c_re, "Longitude", "Float", "", "", "9", "", "NON_NULLABLE", "NON_REQUIRED", "")
arcpy.AddField_management(c_re, "Latitude", "Float", "", "", "9", "", "NON_NULLABLE", "NON_REQUIRED", "")

ERROR 000464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (AddField).

How can I solve this problem?


Try changing:

c_re=arcpy.ExcelToTable_conversion("02_Rea.xlsx", "cg1_re_otim.dbf", "Rea_L")


c_re = "cg1_re_otim.dbf"
arcpy.ExcelToTable_conversion("02_Rea.xlsx", c_re, "Rea_L")

The way you had it is setting your variable c_re to a Result object rather than a string representing a dBase file name, which is what the Add Field tool expects.

  • It gives another error: Runtime error Traceback (most recent call last): File "<string>", line 61, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\conversion.py", line 44, in ExcelToTable raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000725: Output Table: Dataset F:\Otimizacao\interface\cg1_reactiva_otimizada.dbf already exists. Failed to execute (ExcelToTable). – S.Rai Aug 30 '16 at 10:01
  • 1
    That's a new problem so should be researched/asked as a new question, using the new code snippet to illustrate precisely what you ran and the error you received from that code snippet. – PolyGeo Aug 30 '16 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.