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) 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)
share|improve this question
    
I've also tried the Merge without the FOR looping (which seems not necessary), but still have problems with the "Dataset xxx does not exist or is not supported". –  umbe1987 Aug 31 '12 at 17:22
    
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! –  umbe1987 Aug 31 '12 at 19:11
    
Please write a proper reply and then accept it (as per the FAQ). Nice that you managed to solve it by yourself and consider yourself lucky for not running into locking issues. :) –  lynxlynxlynx Aug 31 '12 at 20:51
add comment

1 Answer 1

up vote 0 down vote accepted

It was not a matter of LOCK files. I've just red the help of the Merge_management tool in the ESRI website and couldn't find any reference to dBase tables, therefore I just tried to avoid inserting the extension ".dbf" in the output of the TableToTable_conversion tool and, since I set the name of the output to different than the input by appending a simple "Tab_" prefix, everythinf worked fine so far.

Sorry for the misunderstanding. Anyway, now the task has moved to another topic, You can see it here if You like Create temporary files as intermediate output to be used as input in concatenation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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