Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- # open csv
- csv_test = 'C:/Users/Duygu Altintas/Desktop/FMRTEST.CSV'
- with open(csv_test) as csv_file:
- csv_reader = csv.reader(csv_file, delimiter=',')
- for row in csv_reader:
- # matchHeading = 'SUBCATCHMENTS'
- # matchRow = 'CA-1'
- # editCol = 4
- # valMin = 40
- # valMax = 80
- # valInterval = 5
- matchHeading = row[0]
- matchRow = row[1]
- editCol = int(row[2])
- valMin = int(row[3])
- valMax = int(row[4])
- valInterval = int(row[5])
- print( matchRow, matchHeading, editCol, valMin, valMax, valInterval )
- for val in range(valMin, valMax, valInterval):
- print( val )
- outFileName = "{}.{}.{}.inp".format(matchHeading, matchRow, val)
- swmminput = 'C:/Users/Duygu Altintas/PycharmProjects/FourMileRun/Examples/RUNOFF46_SW5.INP'
- outfile = open('c:/Users/Duygu Altintas/PycharmProjects/FourMileRun/Output' + outFileName, 'w+')
- currentSection = ""
- with open(swmminput, 'r') as inp:
- for cnt, line in enumerate(inp):
- if line.startswith(';'):
- continue
- else:
- if line.startswith('[') and line.strip().endswith(']'):
- currentSection = line.strip()
- if matchHeading in currentSection and len(line.split()) > 1:
- tokens = line.split()
- print( repr( tokens[0].strip()),repr( matchRow ))
- if matchRow == tokens[0].strip():
- print('here is match')
- tokens[editCol] = str(val)
- outfile.write("{}\n".format('\t'.join(tokens)))
- continue
- outfile.write("{}\n".format(line.strip()))
- inp.close()
- outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement