-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparsing.py
More file actions
29 lines (23 loc) · 931 Bytes
/
parsing.py
File metadata and controls
29 lines (23 loc) · 931 Bytes
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
def readfile(filepath):
with open(filepath, "r") as file:
first_line = file.readline()
raw_first_line = first_line.strip().split(" ")
sim_duration = int(raw_first_line[0])
n_intersections = int(raw_first_line[1])
n_streets = int(raw_first_line[2])
n_cars = int(raw_first_line[3])
points = int(raw_first_line[4])
line = file.readline()
line_number = 0
streets = {}
while (line_number < n_streets):
raw_street = line.strip().split(" ")
streets[raw_street[2]] = [int(raw_street[0]), int(raw_street[1]), int(raw_street[3])]
line = file.readline()
line_number += 1
paths = []
while (line != ""):
raw_path = line.strip().split(" ")
paths.append(raw_path[1:])
line = file.readline()
return n_intersections, sim_duration, streets, paths