hsiddique

Simple  script cant see tables (that do exist)

Discussion created by hsiddique on Jun 22, 2011
Latest reply on Jun 23, 2011 by mzcoyle
Hi all,

I have created a script that will take a feature class and various tables, which will then be joined and exported as a shapefile.

The script is
# Name: Update BLPU Points.py
# Author: Halil Siddique
# Description: This scripts will take Uniform data and join the relevent tables
# Date: 17/06/2011

# Create the Geoprocessor object
import arcgisscripting
gp = arcgisscripting.create(9.3)

# Allow Overwrite
gp.OverwriteOutput = 1

# Set Workspace
gp.Workspace = "C:\\datadump"
datadump = gp.workspace

# Input variables from SDE
inputPoint = "C:\\Uniform Data.sde\\UNISDELIVE.UFRM_BLPU_POINT"
inputPR_BLPU = "C:\\Uniform Data.sde\\UNI72LIVE.PR_BLPU"
inputPR_LPI = "C:\\Uniform Data.sde\\UNI72LIVE.PR_LPI"
inputPR_ST_DESC = "C:\\Uniform Data.sde\\UNI72LIVE.PR_ST_DESC"

# Input variables from Datadump folder

pr_blpu = "C:\\datadump\\pr_blpu.dbf"
pr_lpi = "C:\\datadump\\pr_lpi.dbf"
pr_st_desc = "C:\\datadump\\pr_st_desc.dbf"
PR_BLPU_LPI = "C:\\datadump\\PR_BLPU_LPI.dbf"
FINAL_MATCHED = "C:\\datadump\\FINAL_MATCHED.dbf"
#####################################################################
try:
    # Create Feature Layer from BLPU point
    gp.makeFeatureLayer_management(inputPoint, "point_lyr")
    print inputPoint, "is now a feature layer"
    
    # Export PR BLPU to datadump to get OID 
    gp.copyrows_management("inputPR_BLPU", "pr_blpu")
    print "inputPR_BLPU", "has been exported to", datadump
    
    # Create Table View from PR_BLPU
    gp.makeTableView_management("pr_blpu", "PR_BLPU_tbl")
    print "pr_blpu", "is now a table view"

    # Export PR LPI to datadump to get OID 
    gp.copyrows_management("inputPR_LPI", "pr_lpi")
    print "pr_lpi", "has been exported to", datadump
    
    # Create Table View from PR_LPI
    gp.makeTableView_management("pr_lpi", "PR_LPI_tbl")
    print "pr_lpi", "is now a table view"

    # Export PR ST DESC to datadump to get OID 
    gp.copyrows_management("inputPR_ST_DESC", "pr_st_desc")
    print "pr_st_desc", "has been exported to", datadump
    
    # Create Table View from PR_ST_DESC
    gp.makeTableView_management("pr_st_desc", "PR_ST_DESC_tbl")
    print "pr_lpi", "is now a table view"    

    # Join pr_blpu_tbl to pr_lpi 
    gp.AddJoin_management("PR_BLPU_tbl", "KEYVAL", "PR_LPI_tbl", "PKEYVAL")

    # Export Joined table to datadump
    gp.copyrows_management("PR_BLPU_tbl", "PR_BLPU_LPI")

    # Create table view of Joined table (PR_BLPU_LPI)
    gp.makeTableView_management("PR_BLPU_LPI", "PR_BLPU_LPI_tbl")
    print "PR_BLPU_LPI_tbl", "is now a table view"       

    # Join exported table to PR_ST_DESC     
    gp.AddJoin_management("PR_BLPU_LPI_tbl", "ST_KEYVAL", "PR_ST_DESC", "KEYVAL")
    print "PR_BLPU_LPI_tbl, has been joined to PR_ST_DESC"
    
    # Export joined table to Datadump (called FINAL_MATCHED)    
    gp.copyrows_management("PR_BLPU_LPI_tbl", "FINAL MATCHED")
    print "FINAL_MATCHED has been exported"
    
    # Join point layer  with FINAL_MATCHED
    gp.AddJoin_management("point_lyr", "UPRN", "FINAL_MATCHED", "UPRN")
    print "Points has been joined to FINAL_MACTHED"

    # Export Joined Point layer
    gp.copyFeatures_management("point_lyr", "READY_FOR_SDE")
    print "Joined points has been exported to", datadump
except:
    print gp.getmessages()
Now when i run this in pythonwin, i get the following error

>>> C:\Uniform Data.sde\UNISDELIVE.UFRM_BLPU_POINT is now a feature layer
Executing: CopyRows inputPR_BLPU C:\datadump\pr_blpu #
Start Time: Wed Jun 22 17:19:08 2011
Failed to execute. Parameters are not valid.
ERROR 000732: Input Rows: Dataset inputPR_BLPU does not exist or is not supported
Failed to execute (CopyRows).
End Time: Wed Jun 22 17:19:08 2011 (Elapsed Time: 0.00 seconds)
Anyone got any ideas as to why it cannot see the inputPR_BLPU table? It does exist, i've checked within arccatalog etc al.

Cheers

Halil

Outcomes