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 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

share|improve this question
    
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 Oct 25 '12 at 21:59
add comment

1 Answer 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')
share|improve this answer
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. –  Fred Kellner Oct 30 '12 at 17:25
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.