the second picture is the content of the file bf.dat
the language is python
If you have any doubts, please give me comment...
Code:
def parse_scenario(filename):
try:
fp = open(filename, "r")
d = {}
n = int(fp.readline().strip())
d['f_grid'] = []
for i in range(n):
d['f_grid'].append(list(map(int, fp.readline().strip().split(","))))
d['h_grid'] = []
for i in range(n):
d['h_grid'].append(list(map(int, fp.readline().strip().split(","))))
d['i_threshold'] = int(fp.readline().strip())
d['w_direction'] = fp.readline().strip()
d['burn_seeds'] = []
for i in range(d['i_threshold']):
d['burn_seeds'].append(tuple(map(int, fp.readline().strip().split(","))))
return d
except:
return None
print(parse_scenario("bf0.dat"))
print(parse_scenario("bf.dat"))
the second picture is the content of the file bf.dat the language is python Your task is to wite a function parse scenario(filenne) that parses a file with the structure described below, validates t...