2

I am new to coding in python and specifically Arcpy. Through trial and error I was able to piece together this code that was working fine yesterday until I installed service pack 5 for ArcGIs Desktop 10.0, on a 64 bit Windows machine. The reason I decided to install this service pack is because the code was incapable of doing more than ~60 iterations of the loop without stopping unless everything on my machine was closed except ArcCatalog. I saw on a discussion board that updating to a new service pack might solve my problem. Now my problems is the machine crashing halfway through one loop.

Through trial and error I have determined that using the line of my code which calls on the FeatureClassToFeatureClass_conversion crashes ArcCatalog. The only thing that I can trace the problem back to is upgrading to service pack 5.

import arcpy
arcpy.env.scratchWorkspace=r'C:\Users\fk128474\Documents\Freds_Bitterroot_Model\wrf_data\Scratch'
arcpy.env.workspace=r'C:\Users\fk128474\Documents\Freds_Bitterroot_Model\wrf_data\2001_LW'

import os

xcelFiles = arcpy.ListFiles('*.xls')
count = 1

arcpy.env.workspace=r'C:\Users\fk128474\Documents\Freds_Bitterroot_Model\wrf_data\2001_LW'

for count in range(0, 140):
    fileName = xcelFiles[count]
    tableName = fileName[:-4] + '_Table_View'
    layerName = fileName[:-4] + 'Point_Layer'
    xyName = fileName[:-4] + '_pts'
    tempName = 'LW' + fileName[11:-4]

    shpPath = r'C:\Users\fk128474\Documents\Freds_Bitterroot_Model\wrf_data\2001_LW\Shape'
    spRef = r"Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"'

    points = arcpy.MakeTableView_management(fileName + '\\sheet1$', tableName)

    b = arcpy.MakeXYEventLayer_management(points,"F2","F3",tempName, spRef, "F4")
    arcpy.FeatureClassToFeatureClass_conversion (b, shpPath, tempName)

I have not included the rest of my code as this last line causes the program to crash.

Thanks

Fred

1
  • When you say "crash" do you mean you are getting a "Serious Application Error" with the opportunity to send info to Esri? Also, do you need to run this from ArcCatalog? It looks like it should run fine from an IDE like IDLE or from a DOS prompt.
    – PolyGeo
    Commented Oct 25, 2012 at 21:59

1 Answer 1

1

tempName is the name of your temporary layer from MakeXYEventLayer_management so give this a try:

fullshppath = shpPath +'/' + tempName + '.shp'
if arcpy.Exists(fullshppath):
    arcpy.Delete_management(fullshppath)
arcpy.FeatureClassToFeatureClass_conversion (tempName, shpPath, tempName + '.shp')
1
  • 1
    Thank you for your responses. I had to revert to unistalling ArcGIS Desktop on my machine and then reinstalling the program with no service packs. All my code work just fine now. Commented Oct 30, 2012 at 17:25

Your Answer

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

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