Advertisement

07.15.2008 at 03:56PM PDT, ID: 23567950
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.5

Add iteration range to Python script

Asked by mgjust in Python Scripting Language

Hello,

I got the code below from:

http://www.experts-exchange.com/Q_23561733.html

Where can I add a range for the script to use?  I am assuming now it will always start at 001, but, for example, can I make it start at 075?  And is there a way in python to use a list of numbers, if for example I wanted to use an incomplete range (i.e. 412, 450, 460-475)?

Thanks,
MJStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
import csv
 
data = """\
***************************************************************
* THIS FILE CONTAINS THE VALUES OF THE PARAMETERS REQUIRED    *
* FOR THE GEOMOD MODULE, WHICH AUTOMATICALLY IS GENERATED IN  *
* IDRISI. STRONGLY RECOMMEND REEDITING IN IDRISI IF NECESSARY.*
***************************************************************
 
TIME TO BEGIN GEOMOD, INCLUSIVE         :    2001
TIME TO END GEOMOD, INCLUSIVE           :    2016
TIME STEP IN TIME UNITS                 :    1
 
# NEIGHBORS AWAY TO SEARCH,0=NO NIBBLE  :    1
WRITE DEBUG OUTPUT TO LOG FILE,YES=1    :    0
NAME OF STRATA/MASK IMAGE               :    N/A
NAME OF INITIAL LANDUSE IMAGE           :    gr_lc_01b_%03d_fp
DO ENVIR. IMPACT ANALYSIS? 1=YES, 0=NO  :    0
CMP/READ SUITABILITY SCORES(0=CP,1=RD)  :    1
NUMBER OF RUNS ONCE                     :    1
SUITABILITY IMAGE FOR SIMULATION 1      :    c2_mce_%03d
DO VALIDATION ANALYSIS? 1=YES, 0=NO     :    0
SINCE NO VALIDATION IMAGE, LANDUSE CHANGE INFO READ FROM FOLLOWS:
                                  LANDUSE STATE 1       LANDUSE STATE 2
RGNVAL          REGION NAME    # CELLS      BEGIN        END      BEGIN        END
     1             Region 1    %s        %s     %s      %s      %s
 
# OF TIMES OF OUTPUT BESIDE END TIME    :    0
NAME OF OUTPUT LANDUSE IMAGE            :    %s
"""
 
fin = open("c:\\temp\\temp2\\spreadsheet.csv", "rb")  # must be open in binary mode
reader = csv.reader(fin)                 # open reader -- it will parse the csv lines
cnt = 0
 
for cell in reader:                      # through all lines in spreadsheet
    cnt += 1                             # increment the counter
    filename = "output_%03d.gmd" % cnt   # build the filename
    fout = open(filename, "w")           # open the output file for writing
    fout.write(data % (cnt, cnt, 
                       cell[0], cell[1], cell[2], cell[3], cell[4], 
                       filename))
    fout.close()    # close the output file after writing the content
 
fin.close()         # close the spreadsheet
[+][-]07.15.2008 at 11:10PM PDT, ID: 22013546

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.15.2008 at 11:11PM PDT, ID: 22013551

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 09:23AM PDT, ID: 22027131

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 01:50PM PDT, ID: 22030147

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.17.2008 at 02:09PM PDT, ID: 22030366

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 11:10AM PDT, ID: 22038297

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 12:00PM PDT, ID: 22038724

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Python Scripting Language
Sign Up Now!
Solution Provided By: pepr
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.18.2008 at 12:05PM PDT, ID: 22038759

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628