-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.py
49 lines (40 loc) · 1.19 KB
/
parser.py
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
46
from objects import GeneralInfo, Ride, Vehicle
def import_data(path:str):
general_info = None
rides = []
vehicles = []
with open(path, newline='') as csvfile:
first = True
count = 0
for row in csvfile:
a = row.split(sep=" ")
for i, x in enumerate(a):
a[i] = int(x)
if first:
general_info = GeneralInfo(
a[0],
a[1],
a[2],
a[3],
a[4],
a[5]
)
for c in range(0, general_info.float):
vehicles.append(Vehicle(c, 0, 0))
first = False
else:
rides.append(Ride(
count-1,
a[0],
a[1],
a[2],
a[3],
a[4],
a[5]
))
count += 1
return general_info, rides, vehicles
def export_result(path:str, vehicles:list):
with open(path, mode="w+") as out_file:
for v in vehicles:
out_file.write(v.to_export() + "\n")