I am new to Python and to this community as well, hope someone could help me. I am running script to extract and merge toghether the tables of some Raster. Each Attribute Table presents only one row and the same field names. My script works fine until the very end of it, when I try to merge all the tables. It seems the tables are locked (I can see an "sr.lock" file for each Table I want to merge in my folder) and I cannot access them. Strange thing: I do access them if I simply use a sample (for instance) of two of these so created tables in the Python window within arcMap and type their names instead of using a FOR LOOPING... Guess it might have to do with the Here is my script: #import relevant modules, create geoprocessing dispatch object import win32com.client, sys, string, os, arcpy
gp = win32com.client.Dispatch("esriGeoprocessing.gpDispatch.1") # Remember to change this to wherever your files are stored gp.workspace = "G:\\Chile_2012\\MODIS10A2.V005\\provvisoria\\ATTRIBUTE_TABLE" out_dir = "G:\\Chile_2012\\MODIS10A2.V005\\provvisoria\\ATTRIBUTE_TABLE" try: rasters = gp.ListRasters("*", "all") rasters.reset() rst = rasters.Next() while rst: # Create the new field gp.AddField_management (rst, "FILENAME", "text", "", "", "50") # Apply the filename to all entries gp.CalculateField_management (rst, "FILENAME", '"' + rst + '"') rst = rasters.Next() except: print gp.GetMessages () listRaster = arcpy.ListRasters () for raster in listRaster: arcpy.TableToTable_conversion (raster, out_dir, raster+ '.dbf') listTable = arcpy.ListTables () for table in listTable: arcpy.Merge_management (table, 'Cl_Rio_Aconcagua.dbf')
The code is taken from others, I simply adapted it for my needs. Anyway, the error I am receiving so far doesn't have to do explicitly with LOCK topics, but since I have those files in my folder I need help to find out how to get rid of them.
ERROR 000732: Input Datasets: Dataset 'Cl_Rio_Aconcagua_2007121.img.dbf' does not exist or is not supported Failed to execute (Merge)