Create a Loop for Arcpy

المشرف العام

Administrator
طاقم الإدارة
I am looking for help to write a loop a arcpy.CalculateField_maagement process where the User is asked with the 'raw_input', prior to the tool running "Do you need to change a field value(yes/no):",

if he types 'yes' into the input he is then prompted to enter a VB expression to replace a specific field like so "Replace([Column],"Value","newvalue"),

and the calculate field tool runs,if he types 'no' the script skips the Calculate field process and continues on to the next tool,

if the tool has run he is then asked, "Are there anymore fields you wish to update(Yes/no):" if he types 'yes' he is asked to enter another VB expression to replace a field value,

if he types 'no' the script skips the Calculate field process and continues on to the next tool.

I just need help writing the loop I have a giant python application that works but is not flexible in terms of allowing the user to edit data, and this will provide a lot of flexibility by allowing the user to choose if he wishes to edit a value or not.

here is a snippet of where I would like the Loop, I am currently also working on a way to Loop it and will edit the question with any progress I have made.

YesNo = raw_input(Do you need to change a field value(yes/no): ) #Ask User if there is a field value he wants to change, if his answer is yes then he is prompted to enter a SQL query that will run in the the Calculate Field Process, if he says no, the code skips the Calculate Field ProcessVBexp = raw_input("Enter VB Expression to Update Field Names : ") #Enters a replace for his desired field expression arcpy.CalculateField_management("featureclass", "Column", VBexp , "VB", "")Again = raw_input("Are there anymore fields you wish to update(Yes/no): ") #If the user specifies Yes he will be prompted to enter a new VB expression to change a different field & and if he says no the script will continue running

أكثر...
 
أعلى