I have a file on my PC, text.txt that contains these values
5 0, 6 1, 5 2, 4 1 | 5 1
1 1, 4 1, 4 4, 1 4 | 3 3
1 1, 3 3, 4 1, 3 0 | 3 4
and I need to convert to polygons all the values before the symbol |, and to points the last 2 values, correct output would be like this:
poligonos = [[(5,0), (6, 1), (5, 2), (4, 1)],
[(1,1), (4,1), (4, 4), (1, 4)],
[(1, 1), (3, 3), (4, 1), (3, 0)]
]
puntos = [[(5,1)],[(3,3)],[(3,4)]]
In my advance I try to recover polygons like this:
texto = 'texto.txt'
archivo = open(texto)
if archivo is not None:
poligonos = []
puntos = []
valores = archivo.readlines()
for x in valores:
a1, a2 = x.split('|')
poligonos.append(a1.strip().split(' '), a2.strip().split(' '))
print(poligonos)
and in the poligonos.append(a1.strip().split(' '), a2.strip().split(' '))
part it throws TypeError: append() takes exactly one argument (2 given)
What would be the way to separate into polygons and points? Thanks