I am reading in a text file containing several lists with each on its own line. The elements in a given list are non-integer x,y co-ordinates that need to be placed into an array such that:
[x1, y1, x2, y2, x3, y3,....xn, yn]
becomes:
x1 x2 x3....xn
y1 y2 y3....yn
but in the same 2d array.
I'm very new to coding and have tried various methods but to no avail. Right now I am looping over the number of co-ordinate pairs and trying to append the values within the loop but am unsure how to do this.
This is how I have started it:
with open('textfile.txt', 'r') as infile:
for line in infile:
array=[]
number=(line.count(" ")+1)/2 #number of x,y pairs in list
for i in range(0, number-1):
Now I don't know where to go from here so any help would be greatly appreciated! Thanks