Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 (that desappear only when arcgis programs are closed) 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... 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 the problem might be due to that. Even if I don't use the FOR LOOP (which seems not necessary), I always receive this error:

ERROR 000732: Input Datasets: Dataset 'xxx;xxx...' does not exist or is not supported
Failed to execute (Merge)
share|improve this question
    
Solved. It was just a problem with the Merge function cannot reading dbf files, only table views, so I simply modified the output of TableToTable, excluding the extension and changing the name not to be the same of the input, and everything worked so far! –  user9518 Aug 31 '12 at 19:10
1  
YOu might want to answer your own question and accept that answer. That way other people can learn from your experience. –  R.K. Sep 26 '12 at 7:16
    
Question has been answered as Comment which has not been moved to Answer after 4 months => Close vote from me –  PolyGeo Jan 5 '13 at 21:53
add comment

closed as not constructive by PolyGeo, Simon, R.K., whuber Jan 6 '13 at 17:09

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.