-
Notifications
You must be signed in to change notification settings - Fork 0
/
readBestRecord.py
42 lines (35 loc) · 1.11 KB
/
readBestRecord.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
import os
import os.path
import func
import csv
information = []
breakCount = 0
distance = 0
if os.path.isfile('bestResults.csv'):
print("Reading bestResult.csv...\n")
with open('bestResults.csv', mode='r', newline='') as result:
reader = csv.reader(result)
# i = 0
for info in reader:
if info[0] != ';':
information.append(info)
else:
continue
else:
print("ERROR : bestResult.csv not Found")
print("order : ", end='')
print(information[1])
print("\n length : "+str(information[0][0]))
print("generation span : "+str(information[2][0]))
print("population size per generation : "+str(information[3][0]))
print("search pressure : "+str(information[4][0]))
print("\n\n generating solution.csv... \n ")
with open('solution.csv', 'w+', newline='') as solution:
writer = csv.writer(solution)
cityNumber = []
writer.writerow('0') # add city:0 first
for city in information[1]:
cityNumber.append(int(city))
writer.writerow(cityNumber)
cityNumber.clear()
print("solution.csv Generate completed\n")