<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Loop not working in business analyst drive time - python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305743#M10595</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Then try with this indentation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)


# Load required toolboxes...
gp.CheckOutExtension("Business")

gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Business Analyst Tools.tbx")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Script arguments...
for i in range(0,3):
 print i
 s = str(i)
 Input_Store_SHP_File = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Retailers_"+s+".shp" # provide a default value if unspecified
 print Input_Store_SHP_File
 Enter_Drive_Times = "3" # provide a default value if unspecified
 Select_Drive_Time_Polygon_Output_Path = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Result\\Retailers_"+s+".shp" # provide a default value if unspecified

 # Local variables...
 Output_Traversed_Streets_Feature_Class = ""

 # Process: 1 to 20 min Drive Time...
 #tempEnvironment0 = gp.scratchWorkspace
 gp.scratchWorkspace = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\"
 gp.DriveTime_ba(Input_Store_SHP_File, "COMPID", "ALL", Enter_Drive_Times, "Minutes", Select_Drive_Time_Polygon_Output_Path, "", "", "false", "false", "false", "true", "false", "false", Output_Traversed_Streets_Feature_Class)
 #gp.scratchWorkspace = tempEnvironment0
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your problem was that only the first two lines following the "for .. " were taken in the loop because of the indentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cedric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 14:38:20 GMT</pubDate>
    <dc:creator>CedricWannaz</dc:creator>
    <dc:date>2021-12-11T14:38:20Z</dc:date>
    <item>
      <title>Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305738#M10590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have 3 shp files stored in a folder (Retailers_0, Retailers_1 and Retailers_2). I want to create a drive time by looping into each file. Below is the code. The problem I'm having is that it only reads the last file Retailers_2. Can anyone point out what's wrong in the code below?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# ---------------------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# TestDT.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Created on: Mon Jun 21 2010 01:31:26 PM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# (generated by ArcGIS/ModelBuilder)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Usage: TestDT &amp;lt;Input_Store_SHP_File&amp;gt; &amp;lt;Enter_Drive_Times&amp;gt; &amp;lt;Select_Drive_Time_Polygon_Output_Path&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# ---------------------------------------------------------------------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys, string, os, arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Create the Geoprocessor object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Load required toolboxes...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CheckOutExtension("Business")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CheckOutExtension("Network")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Business Analyst Tools.tbx")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for i in range(0,3):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; s = str(i)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print s&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Input_Store_SHP_File = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Retailers_"+s+".shp"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print Input_Store_SHP_File &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Script arguments...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Enter_Drive_Times = "3" # provide a default value if unspecified&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Select_Drive_Time_Polygon_Output_Path = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Result\\Retailers_"+s+".shp" &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Local variables...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_Traversed_Streets_Feature_Class = ""&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Process: 1 to 20 min Drive Time...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#tempEnvironment0 = gp.scratchWorkspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#gp.scratchWorkspace = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Result\\"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.DriveTime_ba(Input_Store_SHP_File, "COMPID", "ALL", Enter_Drive_Times, "Minutes", Select_Drive_Time_Polygon_Output_Path, "", "", "false", "false", "false", "true", "false", "false", Output_Traversed_Streets_Feature_Class)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#gp.scratchWorkspace = tempEnvironment0&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Jun 2010 22:54:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305738#M10590</guid>
      <dc:creator>SabitaTripathi</dc:creator>
      <dc:date>2010-06-21T22:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305739#M10591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Is your code displaying 0, 1, 2 and outputting only the last file or is there even no output? Could you use CODE tags so we can see how your code is indented? You can do it by clicking the sharp (#) button in the editor.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cedric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 12:30:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305739#M10591</guid>
      <dc:creator>CedricWannaz</dc:creator>
      <dc:date>2010-06-22T12:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305740#M10592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It displays 0,1 and 2 but just reads the last file. I edit code with IDLE not pythonwin so sharp button is not there. Let me know if I can do any other way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;H:\FINANCE\Analysis\ESRI\Sabita\NewModel\Test\Retailers_2.shp&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 15:25:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305740#M10592</guid>
      <dc:creator>SabitaTripathi</dc:creator>
      <dc:date>2010-06-22T15:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305741#M10593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, I meant in the forum, as screenshot-ed below.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 15:43:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305741#M10593</guid>
      <dc:creator>CedricWannaz</dc:creator>
      <dc:date>2010-06-22T15:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305742#M10594</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here it is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# ---------------------------------------------------------------------------
# TestDT.py
# Created on: Mon Jun 21 2010 01:31:26 PM
#&amp;nbsp;&amp;nbsp; (generated by ArcGIS/ModelBuilder)
# Usage: TestDT &amp;lt;Input_Store_SHP_File&amp;gt; &amp;lt;Enter_Drive_Times&amp;gt; &amp;lt;Select_Drive_Time_Polygon_Output_Path&amp;gt; 
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)


# Load required toolboxes...
gp.CheckOutExtension("Business")

gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Business Analyst Tools.tbx")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Script arguments...
for i in range(0,3):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print i
&amp;nbsp;&amp;nbsp;&amp;nbsp; s = str(i)
Input_Store_SHP_File = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Retailers_"+s+".shp" # provide a default value if unspecified
print Input_Store_SHP_File
Enter_Drive_Times = "3" # provide a default value if unspecified
Select_Drive_Time_Polygon_Output_Path = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Result\\Retailers_"+s+".shp" # provide a default value if unspecified

# Local variables...
Output_Traversed_Streets_Feature_Class = ""

# Process: 1 to 20 min Drive Time...
#tempEnvironment0 = gp.scratchWorkspace
gp.scratchWorkspace = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\"
gp.DriveTime_ba(Input_Store_SHP_File, "COMPID", "ALL", Enter_Drive_Times, "Minutes", Select_Drive_Time_Polygon_Output_Path, "", "", "false", "false", "false", "true", "false", "false", Output_Traversed_Streets_Feature_Class)
#gp.scratchWorkspace = tempEnvironment0&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:38:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305742#M10594</guid>
      <dc:creator>SabitaTripathi</dc:creator>
      <dc:date>2021-12-11T14:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305743#M10595</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Then try with this indentation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create(9.3)


# Load required toolboxes...
gp.CheckOutExtension("Business")

gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Business Analyst Tools.tbx")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# Script arguments...
for i in range(0,3):
 print i
 s = str(i)
 Input_Store_SHP_File = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Retailers_"+s+".shp" # provide a default value if unspecified
 print Input_Store_SHP_File
 Enter_Drive_Times = "3" # provide a default value if unspecified
 Select_Drive_Time_Polygon_Output_Path = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\Result\\Retailers_"+s+".shp" # provide a default value if unspecified

 # Local variables...
 Output_Traversed_Streets_Feature_Class = ""

 # Process: 1 to 20 min Drive Time...
 #tempEnvironment0 = gp.scratchWorkspace
 gp.scratchWorkspace = "H:\\FINANCE\\Analysis\\ESRI\\Sabita\\NewModel\\Test\\"
 gp.DriveTime_ba(Input_Store_SHP_File, "COMPID", "ALL", Enter_Drive_Times, "Minutes", Select_Drive_Time_Polygon_Output_Path, "", "", "false", "false", "false", "true", "false", "false", Output_Traversed_Streets_Feature_Class)
 #gp.scratchWorkspace = tempEnvironment0
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your problem was that only the first two lines following the "for .. " were taken in the loop because of the indentation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cedric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:38:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305743#M10595</guid>
      <dc:creator>CedricWannaz</dc:creator>
      <dc:date>2021-12-11T14:38:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305744#M10596</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It worked. Thanks a lot!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 16:00:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305744#M10596</guid>
      <dc:creator>SabitaTripathi</dc:creator>
      <dc:date>2010-06-22T16:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Loop not working in business analyst drive time - python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305745#M10597</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My pleasure &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cedric&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jun 2010 16:02:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/loop-not-working-in-business-analyst-drive-time/m-p/305745#M10597</guid>
      <dc:creator>CedricWannaz</dc:creator>
      <dc:date>2010-06-22T16:02:18Z</dc:date>
    </item>
  </channel>
</rss>

