Advertisement
Advertisement
| 07.17.2008 at 01:20PM PDT, ID: 23574794 |
|
[x]
Attachment Details
|
||
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
|