samantha12

Automization of work using python

Discussion created by samantha12 on Jul 12, 2012
Latest reply on Jul 31, 2012 by palffygelfandk
Hi all,

I am new to the python and GIS and need some help..... Ok here is the problem

I have a data set with some 15,000 files . what i have to do is i have to do is i have to run the process in a loop and complete the work. I have the code for processing every single file but please let me know how to use the loop. I am giving the code here..
# ---------------------------------------------------------------------------
# OS.py
# Created on: 2012-07-09 12:13:38.00000
#   (generated by ArcGIS/ModelBuilder)
# Usage: OS <RouteStops> <finalPermitRoute> <outputRouteName>
# Description:
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Check out any necessary licenses
arcpy.CheckOutExtension("Network")

# Script arguments
RouteStops = arcpy.GetParameterAsText(0)
if RouteStops == '#' or not RouteStops:
    RouteStops = "OSOWPRStops10194727" # provide a default value if unspecified

finalPermitRoute = arcpy.GetParameterAsText(1)
if finalPermitRoute == '#' or not finalPermitRoute:
    finalPermitRoute = "C:\\GIS_Data_Map\\Temp\\OSOW.gdb\\Route1" # provide a default value if unspecified

outputRouteName = arcpy.GetParameterAsText(2)
if outputRouteName == '#' or not outputRouteName:
    outputRouteName = "Route1" # provide a default value if unspecified

# Local variables:
streets = "streets"
networkAnalystLayer = RouteStops
networkAnalystLayer2 = networkAnalystLayer
Routes = networkAnalystLayer2
Solve_succeeded = networkAnalystLayer
outputRoute = outputRouteName

# Process: MakeRouteLayer
arcpy.MakeRouteLayer_na(streets, outputRouteName, "Length", "USE_INPUT_ORDER", "PRESERVE_BOTH", "NO_TIMEWINDOWS", "", "ALLOW_UTURNS", "'Non-routeable Segments';OneWay", "USE_HIERARCHY", "", "TRUE_LINES_WITH_MEASURES", "")

# Process: addIntersections
arcpy.AddLocations_na(outputRoute, "Stops", RouteStops, "RouteName # #;Name TripRequID #;TimeWindowStart # #;TimeWindowEnd # #;CurbApproach # 0;Attr_Length # 0;Attr_Time # 0", "5000 Meters", "Rank", "'SDC Edge Source' SHAPE", "MATCH_TO_CLOSEST", "APPEND", "NO_SNAP", "5 Meters", "INCLUDE", "'SDC Edge Source' #")

# Process: Solve
arcpy.Solve_na(networkAnalystLayer, "SKIP", "TERMINATE")

# Process: selectData
arcpy.SelectData_management(networkAnalystLayer2, "Routes")

# Process: copyFeatures
arcpy.CopyFeatures_management(Routes, finalPermitRoute, "", "0", "0", "0")




so please let me know how to loop this for "n" number of files ..........
Thanks
Samantha

Outcomes