HI All,

 

Good Afternoon.

 

I am trying to use if, elif in python script to work on each county. But it works only when the condition is else and jump to the point where I need to work but not for case one or two.

 

Any help or idea is highly appreciated.

 

Thanks in advance.

 

 

 

 

 

 

# script as follows:

# Import system modules

import sys

import string

import os

import win32com.client

import odbc

import shutil

from win32com.client import Dispatch

gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

 

gp.SetProduct("ArcInfo")

gp.workspace = "c:/mydata"

 

try:

    cycle = open('c:/mydata/county_cycle.txt', 'r')

    for countyid in cycle.readlines():

        # for countyid = one, two, thr

        x = countyid.rstrip()

        print x

    

 

        if x=='one':

            county_name = open('c:/mydata/county1.txt', 'r')

            for county in county_name.readlines():

                county = county.rstrip()

                print county

 

        elif x=='two':

            county_name = open('c:/mydata/county2.txt', 'r')

            for county in county_name.readlines():

                county = county.rstrip()

                print county

 

        else:

            county_name = open('c:/mydata/county3.txt', 'r')

            for county in county_name.readlines():

                     

                county = county.rstrip()

                print county

                   

            # the loop come to the next line if the case is else but not for case one or two                

                gp.copy("%smydata1"%county,"%smydata2"%county)

except Exception, ErrDesc:

    print ErrorDesc

Attachment: Script1.py
Description: Script1.py

_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to