I am using jupyter python 3. I have tried to import data from .tsp file but it keeps showing me this error.And I saw some people had same problem and they solved it thanks to convert, but it did not work on my codes.
NAME: berlin52
TYPE: TSP
COMMENT: 52 locations in Berlin (Groetschel)
DIMENSION : 52
EDGE_WEIGHT_TYPE : EUC_2D
NODE_COORD_SECTION
1 565.0 575.0
2 25.0 185.0
3 345.0 750.0
4 945.0 685.0
5 845.0 655.0
6 880.0 660.0
7 25.0 230.0
8 525.0 1000.0
9 580.0 1175.0
10 650.0 1130.0
# Open input file
infile = open(r'C:\Users\13136\OneDrive\Desktop\AI\berlin52.tsp')
# Read instance header
Name = infile.readline().strip().split()[1] # NAME
FileType = infile.readline().strip().split()[1] # TYPE
Comment = infile.readline().strip().split()[1] # COMMENT
Dimension = infile.readline().strip().split()[1] # DIMENSION
EdgeWeightType = infile.readline().strip().split()[1] # EDGE_WEIGHT_TYPE
infile.readline()
# Read node list
nodelist = []
N = int(Dimension)
for i in range(0, int(Dimension)):
x,y = infile.readline().strip().split()[1:]
nodelist.append([float(x), float(y)])
# Close input file
infile.close()
ValueError Traceback (most recent call last)
<ipython-input-22-5e3fe725955a> in <module>
12 # Read node list
13 nodelist = []
---> 14 N = int(Dimension)
15 for i in range(0, int(Dimension)):
16 x,y = infile.readline().strip().split()[1:]
ValueError: invalid literal for int() with base 10: ':'