0

I have a script that's copying files from 2 geodatabases in separate locations into a existing geodatabase on my C:\ Drive. The first part of the script runs workspace3 code perfectly. For some reason the script stops and closes before copying data from workspace4. Am I missing some piece of code that allows it to flow to the next section?

# Import modules
import arcpy, os, string, sys
# Set NEO environment settings
workspace3 = "M:/EIS_DRAFTS/EIS_LAN/Lancaster_UPDM.gdb"
workspace4 = "M:/EIS_DRAFTS/EIS_ORW/Orwell SHP Files/ORWELL UPDM.gdb"

##########################################################################
############################ Workspace3 ##################################
##########################################################################

# Set environment settings
arcpy.env.workspace = workspace3

# Dataset
in_dataset_P_NEO = ['MainComponents','ServiceComponents']

# Dataset
in_dataset_P_PipeSystem = ['P_MeterSetting','P_Pipes',
'P_Service']

#Not included inside a Dataset
in_dataset_P_EverythingElse = ['P_PipelineMarker']

out_dataset_P_NEO = 'C:/EnterpriseFolder/Lancaster.gdb/P_NEO'
out_dataset_P_Integrity = 'C:/EnterpriseFolder/Lancaster.gdb/P_Integrity'
out_dataset_P_PipeSystem = 'C:/EnterpriseFolder/Lancaster.gdb/P_PipeSystem'
out_dataset_P_EverythingElse =     
'C:/EnterpriseFolder/Lancaster.gdb/P_EverythingElse'

# Execute .Exists & .Delete_management
if arcpy.Exists(out_dataset_P_NEO):
arcpy.Delete_management(out_dataset_P_NEO)
if arcpy.Exists(out_dataset_P_PipeSystem):
arcpy.Delete_management(out_dataset_P_PipeSystem)
if arcpy.Exists(out_dataset_P_EverythingElse):
arcpy.Delete_management(out_dataset_P_EverythingElse)


Create_dataset_P_NEO = 'C:/EnterpriseFolder/Lancaster.gdb'
out_name_P_NEO = "P_NEO"

Create_dataset_P_Integrity = 'C:/EnterpriseFolder/Lancaster.gdb'

out_name_P_PipeSystem = "P_PipeSystem"

out_name_P_EverythingElse = "P_EverythingElse"

sr = arcpy.SpatialReference("NAD 1983 UTM Zone 11N")

# Execute .CreateFeaturedataset
arcpy.CreateFeatureDataset_management(Create_dataset_P_NEO, 
out_name_P_NEO,sr)
arcpy.CreateFeatureDataset_management(Create_dataset_P_Integrity,     
out_name_P_PipeSystem,sr)
arcpy.CreateFeatureDataset_management(Create_dataset_P_Integrity,     
out_name_P_EverythingElse,sr)

arcpy.env.outputMFlag = "Disabled"
arcpy.env.outputZFlag = "Disabled"

# Execute .FeatureClassToGeodatabase
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_NEO, 
out_dataset_P_NEO)
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_PipeSystem,         
out_dataset_P_PipeSystem)
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_EverythingElse,     
out_dataset_P_EverythingElse)

print "Finished!"


# Open a log file to write to
#
f = open(r'C:\Lancaster Schedule.log','w')

# Write date/time
#
f.write(time.strftime('%x %X'))
f.write('\n')

# Test receiving of arguments/parameters via arcpy
#
f.write("Parameter 0 : " + arcpy.GetParameterAsText(0) + "\n")

# Python info
#
f.write("Python EXE : " + sys.executable + "\n")
f.write("Architecture : " + platform.architecture()[0] + "\n")
f.write("Path to arcpy : " + imp.find_module("arcpy")[1] + "\n")
f.close()

##########################################################################
############################ Workspace4 ##################################
##########################################################################

# Set environment settings
arcpy.env.workspace = workspace4

# Set local variables
in_dataset_P_Orwell = ['ORWELL_COMPONENTS','ORWELL_FARM_TAPS',
'ORWELL_LINE_MARKERS',
'ORWELL_METERS',
'ORWELL_PIPE_SYSTEM',
'ORWELL_SERVICES',
'ORWELL_STATIONS']

#Dataset
in_dataset_P_Integrity = ['P_Anomaly']

#Dataset
in_dataset_P_PipeSystem = ['P_ExcessFlowValve',
'P_MeterSetting',
'P_NonControllableFitting',
'P_Pipes',
'P_RegulatorStation',
'P_Service',
'P_TownBorderStation',
'P_Valve']

#Not included inside a Dataset
in_dataset_P_EverythingElse = ['P_AbandonedDevice', 'P_AbandonedPipe',
'P_PipelineMarker']

out_dataset_P_Orwell = 'C:/EnterpriseFolder/Orwell.gdb/P_Orwell'
out_dataset_P_Integrity = 'C:/EnterpriseFolder/Orwell.gdb/P_Integrity'
out_dataset_P_PipeSystem = 'C:/EnterpriseFolder/Orwell.gdb/P_PipeSystem'
out_dataset_P_EverythingElse     
='C:/EnterpriseFolder/Orwell.gdb/P_EverythingElse'

# Execute .Exists & .Delete_management
if arcpy.Exists(out_dataset_P_Orwell):
arcpy.Delete_management(out_dataset_P_Orwell)
if arcpy.Exists(out_dataset_P_Integrity):
arcpy.Delete_management(out_dataset_P_Integrity)
if arcpy.Exists(out_dataset_P_PipeSystem):
arcpy.Delete_management(out_dataset_P_PipeSystem)
if arcpy.Exists(out_dataset_P_EverythingElse):
arcpy.Delete_management(out_dataset_P_EverythingElse)


Create_dataset_P_Orwell = 'C:/EnterpriseFolder/Orwell.gdb'
out_name_P_Orwell = "P_Orwell"

Create_dataset_P_Integrity = 'C:/EnterpriseFolder/Orwell.gdb'
out_name_P_Integrity = "P_Integrity"

Create_dataset_P_Integrity = 'C:/EnterpriseFolder/Orwell.gdb'
out_name_P_PipeSystem = "P_PipeSystem"

Create_dataset_P_Integrity = 'C:/EnterpriseFolder/Orwell.gdb'
out_name_P_EverythingElse = "P_EverythingElse"

sr = arcpy.SpatialReference("NAD 1983 UTM Zone 11N")

# Execute .CreateFeaturedataset
arcpy.CreateFeatureDataset_management(Create_dataset_P_Orwell, out_name_P_Orwell,sr)
arcpy.CreateFeatureDataset_management(Create_dataset_P_Integrity, out_name_P_Integrity,sr)
arcpy.CreateFeatureDataset_management(Create_dataset_P_Integrity, out_name_P_PipeSystem,sr)
arcpy.CreateFeatureDataset_management(Create_dataset_P_Integrity,     out_name_P_EverythingElse,sr)

arcpy.env.outputMFlag = "Disabled"
arcpy.env.outputZFlag = "Disabled"

# Execute .FeatureClassToGeodatabase
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_Orwell,     out_dataset_P_Orwell)
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_Integrity,     out_dataset_P_Integrity)
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_PipeSystem,             out_dataset_P_PipeSystem)
arcpy.FeatureClassToGeodatabase_conversion(in_dataset_P_EverythingElse,         
out_dataset_P_EverythingElse)

print "Finished!"

# Open a log file to write to
#
f = open(r'C:\Orwell Schedule.log','w')

# Write date/time
#
f.write(time.strftime('%x %X'))
f.write('\n')

# Test receiving of arguments/parameters via arcpy
#
f.write("Parameter 0 : " + arcpy.GetParameterAsText(0) + "\n")

# Python info
#
f.write("Python EXE : " + sys.executable + "\n")
f.write("Architecture : " + platform.architecture()[0] + "\n")
f.write("Path to arcpy : " + imp.find_module("arcpy")[1] + "\n")
f.close()
1
  • 2
    ESRI rule of thumb: remove space from the folder/file name and try again
    – JGH
    Aug 29, 2017 at 18:05

1 Answer 1

1

I removed this piece of code from each workspace section and it's now working properly.

# Test receiving of arguments/parameters via arcpy
#
f.write("Parameter 0 : " + arcpy.GetParameterAsText(0) + "\n")

# Python info
#
f.write("Python EXE : " + sys.executable + "\n")
f.write("Architecture : " + platform.architecture()[0] + "\n")
f.write("Path to arcpy : " + imp.find_module("arcpy")[1] + "\n")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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