corinnefrey77

Code gets slower and slower

Discussion created by corinnefrey77 on Jul 18, 2012
Latest reply on Jul 18, 2012 by corinnefrey77
Hi

I'm new to phyton and need to convert a bunch of dababase files to shapefiles. I have a batch processing code which is working fine. However, after a while it gets incredibly slow and takes more than an hour for something it took only 10 minutes at the start. I guess that it's somehow a memory - related problem.

Anybody an idea how to clear memory or otherwise fasten the program?

Here is the code:

import arcpy
from arcpy import env
import os

# Set the workspace for the ListFiles function
env.workspace = "g:/CAPAS_Data/N50/"
# Use the ListFile function to return a list
ListDatabase = arcpy.ListFiles("*.mdb")
# print ListDatabase
for x in ListDatabase: 
     env.workspace = "g:/CAPAS_Data/N50/"+x
     
     ListDatasets = arcpy.ListDatasets()

     for y in ListDatasets: 
          env.workspace = "g:/CAPAS_Data/N50/"+x+"/"+y
          ListClasses = arcpy.ListFeatureClasses()

          for z in ListClasses:
               inFeature = [z]
               inFeature_str = str(inFeature)
               outLocation= "g:/CAPAS_Data/shapefiles/"+inFeature_str[3:-2]+"/"

               if not os.path.exists(outLocation):
                    os.makedirs(outLocation)
                    
               arcpy.FeatureClassToShapefile_conversion(inFeature, outLocation)
 


Thanks for any help!
Corinne

Outcomes