Hi,
I am automating LAYER dissolve process through pyhthon almost done.But faced some strange thing today.
While running the python script from ARCMAP every thing is running fine(PFA screenshot), but when I am running same script from PYSCRIPTER or COMMAND Prompt. It shows me Error 000840.
While I am abel to loacte the new created Feature table through catalog, any Idea for same.
Following is the Script for same
# PermanentJoin.py
# Purpose: Join two fields from a table to a feature class
# Author: ESRI
# Import system modules
import arcpy
from arcpy import env
import os
import sys
# Set the local parameters
conStr=r"C:\Users\174314\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\SDE@ME5P.sde"
# Set the current workspace
env.workspace = conStr
levelNameIntial="AZ_US_"
alignment_id=111113
joinField = "ZIP"
joinTable = r"C:\PythonScripts\CSV\lilly_iAlign_10_qc.csv"
csvFileName="lilly_iAlign_10_qc.Csv."
fieldList = []
levelStartCounter=1
levelFielStartCounter=1
totLevel=5
mapEnviornment="QC"
alignmentDataJoinField="zip_code"
#outWorkspace = "c:/Output/output.gdb"
outWorkSpace=""
dissolveFieldName=""
alignmentDatotLeveltaJoinField="ZIP_CODE"
baseZipPoly='SDE.C_ZIP_POLY_2008_ESRI'
mxdFilePath=r'C:\GISWORKAREA\Python'
#Set Qualified name to fase for ommiting longer column name
env.qualifiedFieldNames = False
symbFilePath=r'C:\PythonScripts\Symbology'
connectionFilePath = r'C:\Users\174314\AppData\Roaming\ESRI\Desktop10.1\ArcCatalog\CTSUSADCGISPOC.ags'
def CreateFeatureDataSet(connectiontr,dataSetname):
print 'Feature Dataset creation process start'
sr=""
try:
sr = arcpy.Describe(baseZipPoly).spatialReference
arcpy.CreateFeatureDataset_management(conStr, dataSetname, sr)
except IOError:
print 'Fail to Create Dataset', sys.exc_info()[0]
print 'Feature Dataset creation process start Dataset Name-' + dataSetname
def CreateZipPoly(baseZipPoly,dissolveTableName):
print("ZIP Poly file Creation Start")
try:
arcpy.Copy_management(baseZipPoly,dissolveTableName)
#print(dissolveTableName)
except:
print "Unexpected error While copying ZIP Poly:", sys.exc_info()[0]
print("ZIP Poly file Creation End")
#Creating FeatureDatset
def JoinTable(dissolveTableName,joinField,joinTable, alignmentDataJoinField):
print("Joining Process Start" + dissolveTableName + joinTable)
try:
arcpy.AddJoin_management(dissolveTableName,joinField,joinTable, alignmentDataJoinField,"KEEP_COMMON")
except:
print "Unexpected error While Joining data:", sys.exc_info()[0]
raise
print 'Join process end'
dataSet_name = levelNameIntial + mapEnviornment + "_" + str(alignment_id)
outWorkSpace = os.path.join(conStr, dataSet_name)
dissolveTableName=levelNameIntial + mapEnviornment + "_ZIP_POLY_" + str(alignment_id)
dissolveTableName=os.path.join(outWorkSpace, dissolveTableName)
#Create Data Set
CreateFeatureDataSet(conStr,dataSet_name)
#Create a new ZIP Poly by copying from one existing please ensure baseZipPoly is exist on current schema
CreateZipPoly(baseZipPoly,dissolveTableName)
#Append SDE in front of Dissolve Table for join process
dissolveTableName= "SDE." + levelNameIntial +mapEnviornment + "_ZIP_POLY_" + str(alignment_id)
#Join Process
JoinTable(dissolveTableName,joinField,joinTable, alignmentDataJoinField)